# Pinned third-party Python wheels for the Buck-buildable AORTA CLI.
#
# Wheels are fetched at build time from PyPI by digest; nothing is
# checked into the repo (the wheels themselves do not live in git).
#
# Toolchain context:
#
#   //toolchains:BUCK uses `system_demo_toolchains()` from the bundled
#   prelude, which in turn calls `remote_python_toolchain()`. That
#   downloads a pinned CPython 3.13.6 standalone build from the
#   python-build-standalone project, with per-platform select() over
#   {linux, macos, windows} x {x86_64, arm64}. The interpreter the
#   Buck-built `aorta` binary runs under is therefore deterministic
#   and host-independent: cp313 across all supported platforms.
#
#   That fixes the interpreter ABI (cp313) at config time, but each
#   platform still needs a wheel built for its own (OS, libc, arch).
#   `click` is pure-Python (`py3-none-any`) and works everywhere; the
#   PyYAML wheel is a C extension and must be selected per platform.
#
# Regeneration when bumping a pin:
#   1. Find the matching cp313 wheel URLs on PyPI's "Download files"
#      tab for the package. The interpreter ABI segment must stay
#      `cp313` so it matches the toolchain.
#   2. `curl -fsSL <wheel-url> | sha256sum` to capture each digest.
#   3. Update the URL + sha256 in the select() arms below.
#
# Coverage today: the four (OS, arch) combinations the bundled
# remote_python_toolchain ships a CPython 3.13 build for and where
# PyPI hosts a cp313 PyYAML wheel: linux-{x86_64,aarch64},
# macos-{x86_64,arm64}, windows-x86_64. Hosts outside that matrix
# (e.g. windows-arm64, musl-linux on aarch64) will fail at select()
# resolution with a clear "no matching select arm" error rather than
# at runtime with a less obvious ELF/Mach-O mismatch.

http_file(
    name = "click-wheel",
    urls = [
        "https://files.pythonhosted.org/packages/ee/ae/8e92f8058baf87f6c7d86ee7e457668690195cc77efedb8d3797a06e3940/click-8.4.0-py3-none-any.whl",
    ],
    sha256 = "40c50b7c6c6adac2823d411041ec84f3f103f1b280d5e9ce0d7f998995832f81",
)

prebuilt_python_library(
    name = "click",
    binary_src = ":click-wheel",
    visibility = ["PUBLIC"],
)

# PyYAML 6.0.3 cp313 wheels, one per (OS, arch) the bundled CPython
# toolchain supports. Nested select(): outer arm on OS, inner arm on
# CPU, matching the pattern remote_python_toolchain() uses for its
# own CPython downloads (see prelude/toolchains/python.bzl).
http_file(
    name = "pyyaml-wheel",
    urls = [
        select({
            "prelude//os:linux": select({
                "prelude//cpu:x86_64": "https://files.pythonhosted.org/packages/74/27/e5b8f34d02d9995b80abcef563ea1f8b56d20134d8f4e5e81733b1feceb2/pyyaml-6.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
                "prelude//cpu:arm64": "https://files.pythonhosted.org/packages/50/31/b20f376d3f810b9b2371e72ef5adb33879b25edb7a6d072cb7ca0c486398/pyyaml-6.0.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl",
            }),
            "prelude//os:macos": select({
                "prelude//cpu:x86_64": "https://files.pythonhosted.org/packages/d1/11/0fd08f8192109f7169db964b5707a2f1e8b745d4e239b784a5a1dd80d1db/pyyaml-6.0.3-cp313-cp313-macosx_10_13_x86_64.whl",
                "prelude//cpu:arm64": "https://files.pythonhosted.org/packages/b1/16/95309993f1d3748cd644e02e38b75d50cbc0d9561d21f390a76242ce073f/pyyaml-6.0.3-cp313-cp313-macosx_11_0_arm64.whl",
            }),
            "prelude//os:windows": select({
                "prelude//cpu:x86_64": "https://files.pythonhosted.org/packages/97/c9/39d5b874e8b28845e4ec2202b5da735d0199dbe5b8fb85f91398814a9a46/pyyaml-6.0.3-cp313-cp313-win_amd64.whl",
            }),
        }),
    ],
    sha256 = select({
        "prelude//os:linux": select({
            "prelude//cpu:x86_64": "0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6",
            "prelude//cpu:arm64": "ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c",
        }),
        "prelude//os:macos": select({
            "prelude//cpu:x86_64": "8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8",
            "prelude//cpu:arm64": "2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1",
        }),
        "prelude//os:windows": select({
            "prelude//cpu:x86_64": "79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c",
        }),
    }),
)

prebuilt_python_library(
    name = "pyyaml",
    binary_src = ":pyyaml-wheel",
    visibility = ["PUBLIC"],
)
