diff --git a/.bazelrc b/.bazelrc index c44124d961..66a644e289 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,8 +4,8 @@ # (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it) # To update these lines, execute # `bazel run @rules_bazel_integration_test//tools:update_deleted_packages` -build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered -query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered +build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/python/private,gazelle/pythonconfig,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered +query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/python/private,gazelle/pythonconfig,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered test --test_output=errors diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e5f34d53c..1a1c17d8b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,10 +73,16 @@ Unreleased changes template. Other changes: * (python_repository) Start honoring the `strip_prefix` field for `zstd` archives. +* (pypi) {bzl:obj}`pip_parse.extra_hub_aliases` now works in WORKSPACE files. {#v0-0-0-fixed} ### Fixed * (toolchains) stop depending on `uname` to get the value of the host platform. +* (pypi): Correctly handle multiple versions of the same package in the requirements + files which is useful when including different PyTorch builds (e.g. vs ) for different target platforms. + Fixes ([2337](https://github.com/bazelbuild/rules_python/issues/2337)). +* (uv): Correct the sha256sum for the `uv` binary for aarch64-apple-darwin. + Fixes ([2411](https://github.com/bazelbuild/rules_python/issues/2411)). {#v0-0-0-added} ### Added @@ -87,10 +93,17 @@ Other changes: `RULES_PYTHON_REPO_TOOLCHAIN_{VERSION}_{OS}_{ARCH}` env variable setting. For example, this allows one to use `freethreaded` python interpreter in the `repository_rule` to build a wheel from `sdist`. +* (toolchain) The python interpreters targeting `muslc` libc have been added + for the latest toolchain versions for each minor Python version. You can control + the toolchain selection by using the + {bzl:obj}`//python/config_settings:py_linux_libc` build flag. {#v0-0-0-removed} ### Removed -* Nothing removed. +* (pypi): Remove `pypi_install_dependencies` macro that has been included in + {bzl:obj}`py_repositories` for a long time. +* (bzlmod): Remove `DEFAULT_PYTHON_VERSION` from `interpreters.bzl` file. If + you need the version, please use it from the `versions.bzl` file instead. {#v0-40-0} ## [0.40.0] - 2024-11-17 diff --git a/docs/toolchains.md b/docs/toolchains.md index 6df6f22a2a..d6c59544a8 100644 --- a/docs/toolchains.md +++ b/docs/toolchains.md @@ -451,3 +451,10 @@ The toolchain() calls should be in a separate BUILD file from everything else. This avoids Bazel having to perform unnecessary work when it discovers the list of available toolchains. ::: + +## Toolchain selection flags + +Currently the following flags are used to influence toolchain selection: +* {obj}`--@rules_python//python/config_settings:py_linux_libc` for selecting the Linux libc variant. +* {obj}`--@rules_python//python/config_settings:py_freethreaded` for selecting + the freethreaded experimental Python builds available from `3.13.0` onwards. diff --git a/examples/bzlmod/MODULE.bazel.lock b/examples/bzlmod/MODULE.bazel.lock index d41c509d57..6e4d6e180b 100644 --- a/examples/bzlmod/MODULE.bazel.lock +++ b/examples/bzlmod/MODULE.bazel.lock @@ -1562,7 +1562,7 @@ }, "@@rules_python~//python/extensions:pip.bzl%pip": { "general": { - "bzlTransitiveDigest": "/ClkikmO/rb6gLX+68GdFPtz37IHzx3WRW21jL0nYMs=", + "bzlTransitiveDigest": "qoC5CyCn6Cm4Ytk6NW1xqwmeHlT403IcVg6JXDuLjRU=", "usagesDigest": "/LXEbF0D40bNgP95ES+IlHqvpiKbQBuGdNECrFAUXqk=", "recordedFileInputs": { "@@//requirements_lock_3_10.txt": "5e7083982a7e60f34998579a0ae83b520d46ab8f2552cc51337217f024e6def5", @@ -9486,7 +9486,7 @@ }, "@@rules_python~//python/uv:extensions.bzl%uv": { "general": { - "bzlTransitiveDigest": "umgu1yR4Wmqb1pJa+9hAcs9dPbeqBsPLceKiaEg3DdQ=", + "bzlTransitiveDigest": "wVkXn96Vi6Bn1BRJ4R0bOAbUFvh4k54kimcXSd11Y3g=", "usagesDigest": "wWx9DCrTsAgJQmDRUcO+EJrPKJEDsXpZbjzC0HVdde0=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, diff --git a/python/config_settings/BUILD.bazel b/python/config_settings/BUILD.bazel index 6d34ee95c7..aa26e6e669 100644 --- a/python/config_settings/BUILD.bazel +++ b/python/config_settings/BUILD.bazel @@ -6,6 +6,7 @@ load( "BootstrapImplFlag", "ExecToolsToolchainFlag", "FreeThreadedFlag", + "LibcFlag", "PrecompileFlag", "PrecompileSourceRetentionFlag", ) @@ -13,7 +14,6 @@ load( "//python/private/pypi:flags.bzl", "UniversalWhlFlag", "UseWhlFlag", - "WhlLibcFlag", "define_pypi_internal_flags", ) load(":config_settings.bzl", "construct_config_settings") @@ -87,8 +87,8 @@ string_flag( # This is used for pip and hermetic toolchain resolution. string_flag( name = "py_linux_libc", - build_setting_default = WhlLibcFlag.GLIBC, - values = sorted(WhlLibcFlag.__members__.values()), + build_setting_default = LibcFlag.GLIBC, + values = LibcFlag.flag_values(), # NOTE: Only public because it is used in pip hub and toolchain repos. visibility = ["//visibility:public"], ) diff --git a/python/pip_install/BUILD.bazel b/python/pip_install/BUILD.bazel index 683199f807..09bc46eea7 100644 --- a/python/pip_install/BUILD.bazel +++ b/python/pip_install/BUILD.bazel @@ -35,14 +35,6 @@ bzl_library( deps = ["//python/private/pypi:pip_compile_bzl"], ) -bzl_library( - name = "repositories_bzl", - srcs = ["repositories.bzl"], - deps = [ - "//python/private/pypi:deps_bzl", - ], -) - filegroup( name = "distribution", srcs = glob(["**"]), diff --git a/python/pip_install/repositories.bzl b/python/pip_install/repositories.bzl deleted file mode 100644 index 5231d1f0a1..0000000000 --- a/python/pip_install/repositories.bzl +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"" - -load("//python/private/pypi:deps.bzl", "pypi_deps") - -pip_install_dependencies = pypi_deps diff --git a/python/private/flags.bzl b/python/private/flags.bzl index 5239771d7e..9070f113ac 100644 --- a/python/private/flags.bzl +++ b/python/private/flags.bzl @@ -132,3 +132,14 @@ FreeThreadedFlag = enum( # Do not use freethreaded python toolchain and wheels. NO = "no", ) + +# Determines which libc flavor is preferred when selecting the toolchain and +# linux whl distributions. +# +# buildifier: disable=name-conventions +LibcFlag = FlagEnum( + # Prefer glibc wheels (e.g. manylinux_2_17_x86_64 or linux_x86_64) + GLIBC = "glibc", + # Prefer musl wheels (e.g. musllinux_2_17_x86_64) + MUSL = "musl", +) diff --git a/python/private/pypi/attrs.bzl b/python/private/pypi/attrs.bzl index c6132cb6c1..c9b7ea66a9 100644 --- a/python/private/pypi/attrs.bzl +++ b/python/private/pypi/attrs.bzl @@ -141,6 +141,16 @@ Special values: `host` (for generating deps for the host platform only) and NOTE: this is not for cross-compiling Python wheels but rather for parsing the `whl` METADATA correctly. """, ), + "extra_hub_aliases": attr.string_list_dict( + doc = """\ +Extra aliases to make for specific wheels in the hub repo. This is useful when +paired with the {attr}`whl_modifications`. + +:::{versionadded} 0.38.0 +::: +""", + mandatory = False, + ), "extra_pip_args": attr.string_list( doc = """Extra arguments to pass on to pip. Must not contain spaces. diff --git a/python/private/pypi/config_settings.bzl b/python/private/pypi/config_settings.bzl index 9f3f4d4e48..6f927f2a4c 100644 --- a/python/private/pypi/config_settings.bzl +++ b/python/private/pypi/config_settings.bzl @@ -39,7 +39,8 @@ Note, that here the specialization of musl vs manylinux wheels is the same in order to ensure that the matching fails if the user requests for `musl` and we don't have it or vice versa. """ -load(":flags.bzl", "INTERNAL_FLAGS", "UniversalWhlFlag", "WhlLibcFlag") +load("//python/private:flags.bzl", "LibcFlag") +load(":flags.bzl", "INTERNAL_FLAGS", "UniversalWhlFlag") FLAGS = struct( **{ @@ -251,14 +252,14 @@ def _plat_flag_values(os, cpu, osx_versions, glibc_versions, muslc_versions): elif os == "linux": for os_prefix, linux_libc in { - os: WhlLibcFlag.GLIBC, - "many" + os: WhlLibcFlag.GLIBC, - "musl" + os: WhlLibcFlag.MUSL, + os: LibcFlag.GLIBC, + "many" + os: LibcFlag.GLIBC, + "musl" + os: LibcFlag.MUSL, }.items(): - if linux_libc == WhlLibcFlag.GLIBC: + if linux_libc == LibcFlag.GLIBC: libc_versions = glibc_versions libc_flag = FLAGS.pip_whl_glibc_version - elif linux_libc == WhlLibcFlag.MUSL: + elif linux_libc == LibcFlag.MUSL: libc_versions = muslc_versions libc_flag = FLAGS.pip_whl_muslc_version else: diff --git a/python/private/pypi/extension.bzl b/python/private/pypi/extension.bzl index dc1fb2219e..2ed946fbca 100644 --- a/python/private/pypi/extension.bzl +++ b/python/private/pypi/extension.bzl @@ -710,16 +710,6 @@ The indexes must support Simple API as described here: https://packaging.python.org/en/latest/specifications/simple-repository-api/ """, ), - "extra_hub_aliases": attr.string_list_dict( - doc = """\ -Extra aliases to make for specific wheels in the hub repo. This is useful when -paired with the {attr}`whl_modifications`. - -:::{versionadded} 0.38.0 -::: -""", - mandatory = False, - ), "hub_name": attr.string( mandatory = True, doc = """ diff --git a/python/private/pypi/flags.bzl b/python/private/pypi/flags.bzl index 1e380625ce..11727b5853 100644 --- a/python/private/pypi/flags.bzl +++ b/python/private/pypi/flags.bzl @@ -44,16 +44,6 @@ UniversalWhlFlag = enum( UNIVERSAL = "universal", ) -# Determines which libc flavor is preferred when selecting the linux whl distributions. -# -# buildifier: disable=name-conventions -WhlLibcFlag = enum( - # Prefer glibc wheels (e.g. manylinux_2_17_x86_64 or linux_x86_64) - GLIBC = "glibc", - # Prefer musl wheels (e.g. musllinux_2_17_x86_64) - MUSL = "musl", -) - INTERNAL_FLAGS = [ "dist", "whl_plat", diff --git a/python/private/pypi/parse_requirements.bzl b/python/private/pypi/parse_requirements.bzl index a43217dbc2..133ed18db8 100644 --- a/python/private/pypi/parse_requirements.bzl +++ b/python/private/pypi/parse_requirements.bzl @@ -32,6 +32,20 @@ load(":index_sources.bzl", "index_sources") load(":parse_requirements_txt.bzl", "parse_requirements_txt") load(":whl_target_platforms.bzl", "select_whls") +def _extract_version(entry): + """Extract the version part from the requirement string. + + + Args: + entry: {type}`str` The requirement string. + """ + version_start = entry.find("==") + if version_start != -1: + # Extract everything after '==' until the next space or end of the string + version, _, _ = entry[version_start + 2:].partition(" ") + return version + return None + def parse_requirements( ctx, *, @@ -92,7 +106,7 @@ def parse_requirements( # are returned as just the base package name. e.g., `foo[bar]` results # in an entry like `("foo", "foo[bar] == 1.0 ...")`. requirements_dict = { - normalize_name(entry[0]): entry + (normalize_name(entry[0]), _extract_version(entry[1])): entry for entry in sorted( parse_result.requirements, # Get the longest match and fallback to original WORKSPACE sorting, diff --git a/python/private/pypi/pip_repository.bzl b/python/private/pypi/pip_repository.bzl index 90cda77465..597b37f52c 100644 --- a/python/private/pypi/pip_repository.bzl +++ b/python/private/pypi/pip_repository.bzl @@ -177,6 +177,7 @@ def _pip_repository_impl(rctx): pkg: [whl_alias(repo = rctx.attr.name + "_" + pkg)] for pkg in bzl_packages or [] }, + extra_hub_aliases = rctx.attr.extra_hub_aliases, ) for path, contents in aliases.items(): rctx.file(path, contents) diff --git a/python/private/pythons_hub.bzl b/python/private/pythons_hub.bzl index 8afee5af17..ac928ffc96 100644 --- a/python/private/pythons_hub.bzl +++ b/python/private/pythons_hub.bzl @@ -86,7 +86,6 @@ _interpreters_bzl_template = """ INTERPRETER_LABELS = {{ {interpreter_labels} }} -DEFAULT_PYTHON_VERSION = "{default_python_version}" """ _line_for_hub_template = """\ @@ -125,8 +124,6 @@ def _hub_repo_impl(rctx): rctx.file( "interpreters.bzl", _interpreters_bzl_template.format( - # TODO @aignas 2024-09-28: before 1.0 remove the value from here - default_python_version = rctx.attr.default_python_version, interpreter_labels = interpreter_labels, ), executable = False, diff --git a/python/uv/private/versions.bzl b/python/uv/private/versions.bzl index f13eae5cee..1d68302c74 100644 --- a/python/uv/private/versions.bzl +++ b/python/uv/private/versions.bzl @@ -70,7 +70,7 @@ UV_PLATFORMS = { UV_TOOL_VERSIONS = { "0.4.25": { "aarch64-apple-darwin": struct( - sha256 = "35786030f926e3d34d186edc0ea3989698e57755852af9ae4b39da5109abcbfa", + sha256 = "bb2ff4348114ef220ca52e44d5086640c4a1a18f797a5f1ab6f8559fc37b1230", ), "aarch64-unknown-linux-gnu": struct( sha256 = "4485852eb8013530c4275cd222c0056ce123f92742321f012610f1b241463f39", diff --git a/python/versions.bzl b/python/versions.bzl index d229b9d1db..1fd0649f12 100644 --- a/python/versions.bzl +++ b/python/versions.bzl @@ -248,6 +248,7 @@ TOOL_VERSIONS = { "x86_64-apple-darwin": "193dc7f0284e4917d52b17a077924474882ee172872f2257cfe3375d6d468ed9", "x86_64-pc-windows-msvc": "5069008a237b90f6f7a86956903f2a0221b90d471daa6e4a94831eaa399e3993", "x86_64-unknown-linux-gnu": "c20ee831f7f46c58fa57919b75a40eb2b6a31e03fd29aaa4e8dab4b9c4b60d5d", + "x86_64-unknown-linux-musl": "5c1cc348e317fe7af1acd6a7f665b46eccb554b20d6533f0e76c53f44d4556cc", }, "strip_prefix": "python", }, @@ -367,6 +368,7 @@ TOOL_VERSIONS = { "x86_64-apple-darwin": "90b46dfb1abd98d45663c7a2a8c45d3047a59391d8586d71b459cec7b75f662b", "x86_64-pc-windows-msvc": "e48952619796c66ec9719867b87be97edca791c2ef7fbf87d42c417c3331609e", "x86_64-unknown-linux-gnu": "3db2171e03c1a7acdc599fba583c1b92306d3788b375c9323077367af1e9d9de", + "x86_64-unknown-linux-musl": "ed519c47d9620eb916a6f95ec2875396e7b1a9ab993ee40b2f31b837733f318c", }, "strip_prefix": "python", }, @@ -481,6 +483,7 @@ TOOL_VERSIONS = { "x86_64-apple-darwin": "1e23ffe5bc473e1323ab8f51464da62d77399afb423babf67f8e13c82b69c674", "x86_64-pc-windows-msvc": "647b66ff4552e70aec3bf634dd470891b4a2b291e8e8715b3bdb162f577d4c55", "x86_64-unknown-linux-gnu": "8b50a442b04724a24c1eebb65a36a0c0e833d35374dbdf9c9470d8a97b164cd9", + "x86_64-unknown-linux-musl": "d36fc77a8dd76155a7530f6235999a693b9e7c48aa11afeb5610a091cae5aa6f", }, "strip_prefix": "python", }, @@ -559,6 +562,7 @@ TOOL_VERSIONS = { "x86_64-apple-darwin": "60c5271e7edc3c2ab47440b7abf4ed50fbc693880b474f74f05768f5b657045a", "x86_64-pc-windows-msvc": "f05531bff16fa77b53be0776587b97b466070e768e6d5920894de988bdcd547a", "x86_64-unknown-linux-gnu": "43576f7db1033dd57b900307f09c2e86f371152ac8a2607133afa51cbfc36064", + "x86_64-unknown-linux-musl": "5ed4a4078db3cbac563af66403aaa156cd6e48831d90382a1820db2b120627b5", }, "strip_prefix": "python", }, @@ -572,6 +576,7 @@ TOOL_VERSIONS = { "x86_64-apple-darwin": "cff1b7e7cd26f2d47acac1ad6590e27d29829776f77e8afa067e9419f2f6ce77", "x86_64-pc-windows-msvc": "b25926e8ce4164cf103bacc4f4d154894ea53e07dd3fdd5ebb16fb1a82a7b1a0", "x86_64-unknown-linux-gnu": "2c8cb15c6a2caadaa98af51df6fe78a8155b8471cb3dd7b9836038e0d3657fb4", + "x86_64-unknown-linux-musl": "2f61ee3b628a56aceea63b46c7afe2df3e22a61da706606b0c8efda57f953cf4", "aarch64-apple-darwin-freethreaded": "efc2e71c0e05bc5bedb7a846e05f28dd26491b1744ded35ed82f8b49ccfa684b", "aarch64-unknown-linux-gnu-freethreaded": "59b50df9826475d24bb7eff781fa3949112b5e9c92adb29e96a09cdf1216d5bd", "ppc64le-unknown-linux-gnu-freethreaded": "1217efa5f4ce67fcc9f7eb64165b1bd0912b2a21bc25c1a7e2cb174a21a5df7e", @@ -588,6 +593,7 @@ TOOL_VERSIONS = { "x86_64-apple-darwin": "python", "x86_64-pc-windows-msvc": "python", "x86_64-unknown-linux-gnu": "python", + "x86_64-unknown-linux-musl": "python", "aarch64-apple-darwin-freethreaded": "python/install", "aarch64-unknown-linux-gnu-freethreaded": "python/install", "ppc64le-unknown-linux-gnu-freethreaded": "python/install", @@ -727,6 +733,17 @@ def _generate_platforms(): # Matches the value in @platforms//cpu package arch = "x86_64", ), + "x86_64-unknown-linux-musl": struct( + compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], + flag_values = { + libc: "musl", + }, + os_name = LINUX_NAME, + arch = "x86_64", + ), } freethreaded = Label("//python/config_settings:py_freethreaded") diff --git a/tests/integration/pip_parse/WORKSPACE b/tests/integration/pip_parse/WORKSPACE index db0cd0c7c8..e31655dbe4 100644 --- a/tests/integration/pip_parse/WORKSPACE +++ b/tests/integration/pip_parse/WORKSPACE @@ -7,15 +7,6 @@ load("@rules_python//python:repositories.bzl", "py_repositories", "python_regist py_repositories() -# This call is included in `py_repositories` and we are calling -# `pip_install_dependencies` only to ensure that we are not breaking really old -# code. -# -# TODO @aignas 2024-06-23: remove this before 1.0.0 -load("@rules_python//python/pip_install:repositories.bzl", "pip_install_dependencies") - -pip_install_dependencies() - python_register_toolchains( name = "python39", python_version = "3.9", diff --git a/tests/pypi/parse_requirements/parse_requirements_tests.bzl b/tests/pypi/parse_requirements/parse_requirements_tests.bzl index a6e17bebec..dfa1fef5c3 100644 --- a/tests/pypi/parse_requirements/parse_requirements_tests.bzl +++ b/tests/pypi/parse_requirements/parse_requirements_tests.bzl @@ -19,6 +19,10 @@ load("//python/private/pypi:parse_requirements.bzl", "parse_requirements", "sele def _mock_ctx(): testdata = { + "requirements_different_package_version": """\ +foo==0.0.1+local --hash=sha256:deadbeef +foo==0.0.1 --hash=sha256:deadb00f +""", "requirements_direct": """\ foo[extra] @ https://some-url """, @@ -382,6 +386,48 @@ def _test_env_marker_resolution(env): _tests.append(_test_env_marker_resolution) +def _test_different_package_version(env): + got = parse_requirements( + ctx = _mock_ctx(), + requirements_by_platform = { + "requirements_different_package_version": ["linux_x86_64"], + }, + ) + env.expect.that_dict(got).contains_exactly({ + "foo": [ + struct( + distribution = "foo", + extra_pip_args = [], + requirement_line = "foo==0.0.1 --hash=sha256:deadb00f", + srcs = struct( + requirement = "foo==0.0.1", + shas = ["deadb00f"], + version = "0.0.1", + ), + target_platforms = ["linux_x86_64"], + whls = [], + sdist = None, + is_exposed = True, + ), + struct( + distribution = "foo", + extra_pip_args = [], + requirement_line = "foo==0.0.1+local --hash=sha256:deadbeef", + srcs = struct( + requirement = "foo==0.0.1+local", + shas = ["deadbeef"], + version = "0.0.1+local", + ), + target_platforms = ["linux_x86_64"], + whls = [], + sdist = None, + is_exposed = True, + ), + ], + }) + +_tests.append(_test_different_package_version) + def parse_requirements_test_suite(name): """Create the test suite.