Skip to content

Commit 9f291c3

Browse files
authored
refactor: call a function to define internal pypi flags instead of listcomp (#2011)
This is updated so tooling can more automatically process the files. In particular, it helps tools, like buildozer, process the files, which makes it easier to import the code into Google. This is because there is a named target that buildozer can be told to process, whereas, with a list comprehension, it's an arbitrary chunk of code that has to be patched, without an identifiable label.
1 parent 5b2564a commit 9f291c3

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

python/config_settings/BUILD.bazel

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ load(
1010
)
1111
load(
1212
"//python/private/pypi:flags.bzl",
13-
"INTERNAL_FLAGS",
1413
"UniversalWhlFlag",
1514
"UseWhlFlag",
1615
"WhlLibcFlag",
16+
"define_pypi_internal_flags",
1717
)
1818
load(":config_settings.bzl", "construct_config_settings")
1919

@@ -163,14 +163,6 @@ string_flag(
163163
visibility = ["//visibility:public"],
164164
)
165165

166-
# private pip whl related flags. Their values cannot be changed and they
167-
# are an implementation detail of how `pip_config_settings` work.
168-
[
169-
string_flag(
170-
name = "_internal_pip_" + flag,
171-
build_setting_default = "",
172-
values = [""],
173-
visibility = ["//visibility:public"],
174-
)
175-
for flag in INTERNAL_FLAGS
176-
]
166+
define_pypi_internal_flags(
167+
name = "define_pypi_internal_flags",
168+
)

python/private/pypi/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ bzl_library(
9292
bzl_library(
9393
name = "flags_bzl",
9494
srcs = ["flags.bzl"],
95-
deps = ["//python/private:enum_bzl"],
95+
deps = [
96+
"//python/private:enum_bzl",
97+
"@bazel_skylib//rules:common_settings",
98+
],
9699
)
97100

98101
bzl_library(

python/private/pypi/flags.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ NOTE: The transitive loads of this should be kept minimal. This avoids loading
1818
unnecessary files when all that are needed are flag definitions.
1919
"""
2020

21+
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
2122
load("//python/private:enum.bzl", "enum")
2223

2324
# Determines if we should use whls for third party
@@ -68,3 +69,12 @@ INTERNAL_FLAGS = [
6869
"whl_pycp3x_abi3",
6970
"whl_pycp3x_abicp",
7071
]
72+
73+
def define_pypi_internal_flags(name):
74+
for flag in INTERNAL_FLAGS:
75+
string_flag(
76+
name = "_internal_pip_" + flag,
77+
build_setting_default = "",
78+
values = [""],
79+
visibility = ["//visibility:public"],
80+
)

0 commit comments

Comments
 (0)