Skip to content

Commit 0f9954e

Browse files
committed
comment: pass loaded_platform structs
1 parent 465111e commit 0f9954e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

python/private/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ bzl_library(
256256
deps = [
257257
":py_toolchain_suite_bzl",
258258
":text_util_bzl",
259+
"//python:versions_bzl",
259260
],
260261
)
261262

python/private/pythons_hub.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"Repo rule used by bzlmod extension to create a repo that has a map of Python interpreters and their labels"
1616

17+
load("//python:versions.bzl", "PLATFORMS")
1718
load(":text_util.bzl", "render")
1819
load(":toolchains_repo.bzl", "python_toolchain_build_file_content")
1920

@@ -66,7 +67,11 @@ def _hub_build_file_content(
6667
python_version = python_versions[i],
6768
set_python_version_constraint = set_python_version_constraints[i],
6869
user_repository_name = user_repository_names[i],
69-
loaded_platforms = loaded_platforms[python_versions[i]],
70+
loaded_platforms = {
71+
k: v
72+
for k, v in PLATFORMS.items()
73+
if k in loaded_platforms[python_versions[i]]
74+
},
7075
)
7176
for i in range(len(python_versions))
7277
],

python/private/toolchains_repo.bzl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def python_toolchain_build_file_content(
5252
have the Python version constraint added as a requirement for
5353
matching the toolchain, "False" if not.
5454
user_repository_name: names for the user repos
55-
loaded_platforms: the list of platform identifiers for which to generate
56-
the toolchain targets.
55+
loaded_platforms: {type}`struct` the list of platform structs defining the
56+
loaded platforms. It is as they are defined in `//python:versions.bzl`.
5757
5858
Returns:
5959
build_content: Text containing toolchain definitions
@@ -80,8 +80,7 @@ py_toolchain_suite(
8080
prefix = prefix,
8181
python_version = python_version,
8282
)
83-
for platform, meta in PLATFORMS.items()
84-
if platform in loaded_platforms
83+
for platform, meta in loaded_platforms.items()
8584
])
8685

8786
def _toolchains_repo_impl(rctx):
@@ -104,7 +103,11 @@ load("@{rules_python}//python/private:py_toolchain_suite.bzl", "py_toolchain_sui
104103
python_version = rctx.attr.python_version,
105104
set_python_version_constraint = str(rctx.attr.set_python_version_constraint),
106105
user_repository_name = rctx.attr.user_repository_name,
107-
loaded_platforms = rctx.attr.platforms,
106+
loaded_platforms = {
107+
k: v
108+
for k, v in PLATFORMS.items()
109+
if k in rctx.attr.platforms
110+
},
108111
)
109112

110113
rctx.file("BUILD.bazel", build_content + toolchains)

0 commit comments

Comments
 (0)