Skip to content

Commit 7d81375

Browse files
committed
Merge branch 'refactor/remove-uname-dep' into feat/musl-linux-toolchain
2 parents 758f4d6 + c5b8b16 commit 7d81375

File tree

14 files changed

+189
-496
lines changed

14 files changed

+189
-496
lines changed

.bcr/gazelle/presubmit.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ bcr_test_module:
1616
module_path: "../examples/bzlmod_build_file_generation"
1717
matrix:
1818
platform: ["debian11", "macos", "ubuntu2004", "windows"]
19-
bazel: [6.x, 7.x]
19+
# last_rc is to get latest 8.x release. Replace with 8.x when available.
20+
bazel: [7.x, last_rc]
2021
tasks:
2122
run_tests:
2223
name: "Run test module"

.bcr/presubmit.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ bcr_test_module:
1616
module_path: "examples/bzlmod"
1717
matrix:
1818
platform: ["debian11", "macos", "ubuntu2004", "windows"]
19-
bazel: [6.x, 7.x]
19+
# last_rc is to get latest 8.x release. Replace with 8.x when available.
20+
bazel: [7.x, last_rc]
2021
tasks:
2122
run_tests:
2223
name: "Run test module"

CHANGELOG.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,46 @@ Unreleased changes template.
5252

5353
{#v0-0-0-changed}
5454
### Changed
55-
* Nothing yet.
55+
56+
**Breaking**:
57+
* (toolchains) stop exposing config settings in python toolchain alias repos.
58+
Please consider depending on the flags defined in
59+
`//python/config_setting/...` and the `@platforms` package instead.
60+
* (toolchains) consumers who were depending on the `MACOS_NAME` and the `arch`
61+
attribute in the `PLATFORMS` list, please update your code to respect the new
62+
values. The values now correspond to the values available in the
63+
`@platforms//` package constraint values.
64+
* (toolchains) `host_platform` and `interpreter` constants are no longer created
65+
in the `toolchain` generated alias `.bzl` files. If you need to access the
66+
host interpreter during the `repository_rule` evaluation, please use the
67+
`@python_{version}_host//:python` targets created by
68+
{bzl:obj}`python_register_toolchains` and
69+
{bzl:obj}`python_register_multi_toolchains` macros or the {bzl:obj}`python`
70+
bzlmod extension.
71+
72+
Other changes:
73+
* Nothing yet
5674

5775
{#v0-0-0-fixed}
5876
### Fixed
59-
* Nothing yet.
77+
* (toolchains) stop depending on `uname` to get the value of the host platform.
6078

6179
{#v0-0-0-added}
6280
### Added
81+
* (toolchains) allow users to select which variant of the support host toolchain
82+
they would like to use through
83+
`RULES_PYTHON_REPO_TOOLCHAIN_{VERSION}_{OS}_{ARCH}` env variable setting. For
84+
example, this allows one to use `freethreaded` python interpreter in the
85+
`repository_rule` to build a wheel from `sdist`.
6386
* (toolchain) The python interpreters targeting `muslc` libc have been added
6487
for the latest toolchain versions for each minor Python version. You can control
6588
the toolchain selection by using the
6689
{bzl:obj}`//python/config_settings:py_linux_libc` build flag.
6790

6891
{#v0-0-0-removed}
6992
### Removed
70-
* Nothing yet.
93+
* (publish) Remove deprecated `requirements.txt` for the `twine` dependencies.
94+
Please use `requirements_linux.txt` instead.
7195

7296
{#v0-39-0}
7397
## [0.39.0] - 2024-11-13

MODULE.bazel

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,7 @@ bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True)
8484
# We use `WORKSPACE.bzlmod` because it is impossible to have dev-only local overrides.
8585
bazel_dep(name = "rules_go", version = "0.41.0", dev_dependency = True, repo_name = "io_bazel_rules_go")
8686
bazel_dep(name = "rules_python_gazelle_plugin", version = "0", dev_dependency = True)
87-
bazel_dep(name = "gazelle", version = "0.33.0", dev_dependency = True, repo_name = "bazel_gazelle")
88-
single_version_override(
89-
module_name = "gazelle",
90-
patch_strip = 1,
91-
patches = [
92-
# Can be removed once https://github.com/bazel-contrib/bazel-gazelle/issues/1959
93-
# is fixed and released.
94-
"patches/gazelle_native_sh.patch",
95-
],
96-
version = "0.33.0",
97-
)
87+
bazel_dep(name = "gazelle", version = "0.40.0", dev_dependency = True, repo_name = "bazel_gazelle")
9888

9989
internal_dev_deps = use_extension(
10090
"//python/private:internal_dev_deps.bzl",

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps
8686
_py_gazelle_deps()
8787

8888
# This interpreter is used for various rules_python dev-time tools
89-
load("@python//3.11.9:defs.bzl", "interpreter")
89+
interpreter = "@python_3_11_9_host//:python"
9090

9191
#####################
9292
# Install twine for our own runfiles wheel publishing.
@@ -98,7 +98,7 @@ pip_parse(
9898
name = "rules_python_publish_deps",
9999
python_interpreter_target = interpreter,
100100
requirements_darwin = "//tools/publish:requirements_darwin.txt",
101-
requirements_lock = "//tools/publish:requirements.txt",
101+
requirements_lock = "//tools/publish:requirements_linux.txt",
102102
requirements_windows = "//tools/publish:requirements_windows.txt",
103103
)
104104

patches/gazelle_native_sh.patch

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

private/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ multirun(
88
"//tools/publish:{}.update".format(r)
99
for r in [
1010
"requirements_universal",
11-
"requirements",
1211
"requirements_darwin",
1312
"requirements_windows",
1413
"requirements_linux",

python/private/python_register_toolchains.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,11 @@ def python_register_toolchains(
160160
platform = platform,
161161
))
162162

163-
host_toolchain(name = name + "_host")
163+
host_toolchain(
164+
name = name + "_host",
165+
platforms = loaded_platforms,
166+
python_version = python_version,
167+
)
164168

165169
toolchain_aliases(
166170
name = name,
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright 2024 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Create toolchain alias targets."""
16+
17+
load("@rules_python//python:versions.bzl", "PLATFORMS")
18+
19+
def toolchain_aliases(*, name, platforms, visibility = None, native = native):
20+
"""Cretae toolchain aliases for the python toolchains.
21+
22+
Args:
23+
name: {type}`str` The name of the current repository.
24+
platforms: {type}`platforms` The list of platforms that are supported
25+
for the current toolchain repository.
26+
visibility: {type}`list[Target] | None` The visibility of the aliases.
27+
native: The native struct used in the macro, useful for testing.
28+
"""
29+
for platform in PLATFORMS.keys():
30+
if platform not in platforms:
31+
continue
32+
33+
native.config_setting(
34+
name = platform,
35+
flag_values = PLATFORMS[platform].flag_values,
36+
constraint_values = PLATFORMS[platform].compatible_with,
37+
visibility = ["//visibility:private"],
38+
)
39+
40+
prefix = name
41+
for name in [
42+
"files",
43+
"includes",
44+
"libpython",
45+
"py3_runtime",
46+
"python_headers",
47+
"python_runtimes",
48+
]:
49+
native.alias(
50+
name = name,
51+
actual = select({
52+
":" + platform: "@{}_{}//:{}".format(prefix, platform, name)
53+
for platform in platforms
54+
}),
55+
visibility = visibility,
56+
)
57+
58+
native.alias(
59+
name = "python3",
60+
actual = select({
61+
":" + platform: "@{}_{}//:{}".format(prefix, platform, "python.exe" if "windows" in platform else "bin/python3")
62+
for platform in platforms
63+
}),
64+
visibility = visibility,
65+
)
66+
native.alias(
67+
name = "pip",
68+
actual = select({
69+
":" + platform: "@{}_{}//:python_runtimes".format(prefix, platform)
70+
for platform in platforms
71+
if "windows" not in platform
72+
}),
73+
visibility = visibility,
74+
)

0 commit comments

Comments
 (0)