Skip to content

Commit d7e1431

Browse files
committed
Merge branch 'main' into chore/pip-parse-rm-deprecated
2 parents b4c7f0a + d52b964 commit d7e1431

File tree

19 files changed

+136
-75
lines changed

19 files changed

+136
-75
lines changed

.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it)
55
# To update these lines, execute
66
# `bazel run @rules_bazel_integration_test//tools:update_deleted_packages`
7-
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
8-
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
7+
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
8+
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
99

1010
test --test_output=errors
1111

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,16 @@ Unreleased changes template.
7373

7474
Other changes:
7575
* (python_repository) Start honoring the `strip_prefix` field for `zstd` archives.
76+
* (pypi) {bzl:obj}`pip_parse.extra_hub_aliases` now works in WORKSPACE files.
7677

7778
{#v0-0-0-fixed}
7879
### Fixed
7980
* (toolchains) stop depending on `uname` to get the value of the host platform.
81+
* (pypi): Correctly handle multiple versions of the same package in the requirements
82+
files which is useful when including different PyTorch builds (e.g. <pytorch+cpu> vs <pytorch+cu118> ) for different target platforms.
83+
Fixes ([2337](https://github.com/bazelbuild/rules_python/issues/2337)).
84+
* (uv): Correct the sha256sum for the `uv` binary for aarch64-apple-darwin.
85+
Fixes ([2411](https://github.com/bazelbuild/rules_python/issues/2411)).
8086

8187
{#v0-0-0-added}
8288
### Added
@@ -87,10 +93,17 @@ Other changes:
8793
`RULES_PYTHON_REPO_TOOLCHAIN_{VERSION}_{OS}_{ARCH}` env variable setting. For
8894
example, this allows one to use `freethreaded` python interpreter in the
8995
`repository_rule` to build a wheel from `sdist`.
96+
* (toolchain) The python interpreters targeting `muslc` libc have been added
97+
for the latest toolchain versions for each minor Python version. You can control
98+
the toolchain selection by using the
99+
{bzl:obj}`//python/config_settings:py_linux_libc` build flag.
90100

91101
{#v0-0-0-removed}
92102
### Removed
93-
* Nothing removed.
103+
* (pypi): Remove `pypi_install_dependencies` macro that has been included in
104+
{bzl:obj}`py_repositories` for a long time.
105+
* (bzlmod): Remove `DEFAULT_PYTHON_VERSION` from `interpreters.bzl` file. If
106+
you need the version, please use it from the `versions.bzl` file instead.
94107

95108
{#v0-40-0}
96109
## [0.40.0] - 2024-11-17

docs/toolchains.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,3 +451,10 @@ The toolchain() calls should be in a separate BUILD file from everything else.
451451
This avoids Bazel having to perform unnecessary work when it discovers the list
452452
of available toolchains.
453453
:::
454+
455+
## Toolchain selection flags
456+
457+
Currently the following flags are used to influence toolchain selection:
458+
* {obj}`--@rules_python//python/config_settings:py_linux_libc` for selecting the Linux libc variant.
459+
* {obj}`--@rules_python//python/config_settings:py_freethreaded` for selecting
460+
the freethreaded experimental Python builds available from `3.13.0` onwards.

examples/bzlmod/MODULE.bazel.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/config_settings/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ load(
66
"BootstrapImplFlag",
77
"ExecToolsToolchainFlag",
88
"FreeThreadedFlag",
9+
"LibcFlag",
910
"PrecompileFlag",
1011
"PrecompileSourceRetentionFlag",
1112
)
1213
load(
1314
"//python/private/pypi:flags.bzl",
1415
"UniversalWhlFlag",
1516
"UseWhlFlag",
16-
"WhlLibcFlag",
1717
"define_pypi_internal_flags",
1818
)
1919
load(":config_settings.bzl", "construct_config_settings")
@@ -87,8 +87,8 @@ string_flag(
8787
# This is used for pip and hermetic toolchain resolution.
8888
string_flag(
8989
name = "py_linux_libc",
90-
build_setting_default = WhlLibcFlag.GLIBC,
91-
values = sorted(WhlLibcFlag.__members__.values()),
90+
build_setting_default = LibcFlag.GLIBC,
91+
values = LibcFlag.flag_values(),
9292
# NOTE: Only public because it is used in pip hub and toolchain repos.
9393
visibility = ["//visibility:public"],
9494
)

python/pip_install/BUILD.bazel

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ bzl_library(
3535
deps = ["//python/private/pypi:pip_compile_bzl"],
3636
)
3737

38-
bzl_library(
39-
name = "repositories_bzl",
40-
srcs = ["repositories.bzl"],
41-
deps = [
42-
"//python/private/pypi:deps_bzl",
43-
],
44-
)
45-
4638
filegroup(
4739
name = "distribution",
4840
srcs = glob(["**"]),

python/pip_install/repositories.bzl

Lines changed: 0 additions & 19 deletions
This file was deleted.

python/private/flags.bzl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,14 @@ FreeThreadedFlag = enum(
132132
# Do not use freethreaded python toolchain and wheels.
133133
NO = "no",
134134
)
135+
136+
# Determines which libc flavor is preferred when selecting the toolchain and
137+
# linux whl distributions.
138+
#
139+
# buildifier: disable=name-conventions
140+
LibcFlag = FlagEnum(
141+
# Prefer glibc wheels (e.g. manylinux_2_17_x86_64 or linux_x86_64)
142+
GLIBC = "glibc",
143+
# Prefer musl wheels (e.g. musllinux_2_17_x86_64)
144+
MUSL = "musl",
145+
)

python/private/pypi/attrs.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ Special values: `host` (for generating deps for the host platform only) and
141141
NOTE: this is not for cross-compiling Python wheels but rather for parsing the `whl` METADATA correctly.
142142
""",
143143
),
144+
"extra_hub_aliases": attr.string_list_dict(
145+
doc = """\
146+
Extra aliases to make for specific wheels in the hub repo. This is useful when
147+
paired with the {attr}`whl_modifications`.
148+
149+
:::{versionadded} 0.38.0
150+
:::
151+
""",
152+
mandatory = False,
153+
),
144154
"extra_pip_args": attr.string_list(
145155
doc = """Extra arguments to pass on to pip. Must not contain spaces.
146156

python/private/pypi/config_settings.bzl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ Note, that here the specialization of musl vs manylinux wheels is the same in
3939
order to ensure that the matching fails if the user requests for `musl` and we don't have it or vice versa.
4040
"""
4141

42-
load(":flags.bzl", "INTERNAL_FLAGS", "UniversalWhlFlag", "WhlLibcFlag")
42+
load("//python/private:flags.bzl", "LibcFlag")
43+
load(":flags.bzl", "INTERNAL_FLAGS", "UniversalWhlFlag")
4344

4445
FLAGS = struct(
4546
**{
@@ -251,14 +252,14 @@ def _plat_flag_values(os, cpu, osx_versions, glibc_versions, muslc_versions):
251252

252253
elif os == "linux":
253254
for os_prefix, linux_libc in {
254-
os: WhlLibcFlag.GLIBC,
255-
"many" + os: WhlLibcFlag.GLIBC,
256-
"musl" + os: WhlLibcFlag.MUSL,
255+
os: LibcFlag.GLIBC,
256+
"many" + os: LibcFlag.GLIBC,
257+
"musl" + os: LibcFlag.MUSL,
257258
}.items():
258-
if linux_libc == WhlLibcFlag.GLIBC:
259+
if linux_libc == LibcFlag.GLIBC:
259260
libc_versions = glibc_versions
260261
libc_flag = FLAGS.pip_whl_glibc_version
261-
elif linux_libc == WhlLibcFlag.MUSL:
262+
elif linux_libc == LibcFlag.MUSL:
262263
libc_versions = muslc_versions
263264
libc_flag = FLAGS.pip_whl_muslc_version
264265
else:

0 commit comments

Comments
 (0)