Skip to content

Commit c94f2fa

Browse files
committed
chore(pypi): remove unused config settings code
1 parent b0d29fb commit c94f2fa

9 files changed

Lines changed: 5 additions & 222 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pip = use_extension("//python/extensions:pip.bzl", "pip")
7676
"//python/config_settings:_is_py_freethreaded_{}".format(
7777
"yes" if freethreaded else "no",
7878
),
79+
"//python/config_settings:_is_py_linux_libc_glibc",
7980
],
8081
env = {"platform_version": "0"},
8182
marker = "python_version >= '3.13'" if freethreaded else "",

docs/api/rules_python/python/config_settings/index.md

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -274,60 +274,6 @@ the values used when environment markers are resolved at build time.
274274
:::
275275
::::
276276

277-
::::{bzl:flag} pip_whl
278-
Set what distributions are used in the `pip` integration.
279-
280-
Values:
281-
* `auto`: Prefer `whl` distributions if they are compatible with a target
282-
platform, but fallback to `sdist`. This is the default.
283-
* `only`: Only use `whl` distributions and error out if it is not available.
284-
* `no`: Only use `sdist` distributions. The wheels will be built non-hermetically in the `whl_library` repository rule.
285-
:::{versionadded} 0.33.0
286-
:::
287-
::::
288-
289-
::::{bzl:flag} pip_whl_osx_arch
290-
Set what wheel types we should prefer when building on the OSX platform.
291-
292-
Values:
293-
* `arch`: Prefer architecture specific wheels.
294-
* `universal`: Prefer universal wheels that usually are bigger and contain binaries for both, Intel and ARM architectures in the same wheel.
295-
:::{versionadded} 0.33.0
296-
:::
297-
::::
298-
299-
::::{bzl:flag} pip_whl_glibc_version
300-
Set the minimum `glibc` version that the `py_binary` using `whl` distributions from a PyPI index should support.
301-
302-
Values:
303-
* `""`: Select the lowest available version of each wheel giving you the maximum compatibility. This is the default.
304-
* `X.Y`: The string representation of a `glibc` version. The allowed values depend on the `requirements.txt` lock file contents.
305-
:::{versionadded} 0.33.0
306-
:::
307-
::::
308-
309-
::::{bzl:flag} pip_whl_muslc_version
310-
Set the minimum `muslc` version that the `py_binary` using `whl` distributions from a PyPI index should support.
311-
312-
Values:
313-
* `""`: Select the lowest available version of each wheel giving you the maximum compatibility. This is the default.
314-
* `X.Y`: The string representation of a `muslc` version. The allowed values depend on the `requirements.txt` lock file contents.
315-
:::{versionadded} 0.33.0
316-
:::
317-
::::
318-
319-
::::{bzl:flag} pip_whl_osx_version
320-
Set the minimum `osx` version that the `py_binary` using `whl` distributions from a PyPI index should support.
321-
322-
Values:
323-
* `""`: Select the lowest available version of each wheel giving you the maximum compatibility. This is the default.
324-
* `X.Y`: The string representation of the MacOS version. The allowed values depend on the `requirements.txt` lock file contents.
325-
326-
:::{versionadded} 0.33.0
327-
:::
328-
::::
329-
330-
331277
::::
332278

333279
:::{flag} venvs_site_packages

docs/pypi/download.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,6 @@ that by parsing the `whl` filename based on [PEP600], [PEP656] standards. This
244244
allows the user to configure the behaviour by using the following publicly
245245
available flags:
246246
* {obj}`--@rules_python//python/config_settings:py_linux_libc` for selecting the Linux libc variant.
247-
* {obj}`--@rules_python//python/config_settings:pip_whl` for selecting `whl` distribution preference.
248-
* {obj}`--@rules_python//python/config_settings:pip_whl_osx_arch` for selecting MacOS wheel preference.
249-
* {obj}`--@rules_python//python/config_settings:pip_whl_glibc_version` for selecting the GLIBC version compatibility.
250-
* {obj}`--@rules_python//python/config_settings:pip_whl_muslc_version` for selecting the musl version compatibility.
251-
* {obj}`--@rules_python//python/config_settings:pip_whl_osx_version` for selecting MacOS version compatibility.
252247

253248
[bazel_downloader]: https://bazel.build/rules/lib/builtins/repository_ctx#download
254249
[pep600]: https://peps.python.org/pep-0600/

python/config_settings/BUILD.bazel

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ load(
1414
"VenvsUseDeclareSymlinkFlag",
1515
rp_string_flag = "string_flag",
1616
)
17-
load(
18-
"//python/private/pypi:flags.bzl",
19-
"UniversalWhlFlag",
20-
"UseWhlFlag",
21-
"define_pypi_internal_flags",
22-
)
17+
load("//python/private/pypi:flags.bzl", "define_pypi_internal_flags")
2318
load(":config_settings.bzl", "construct_config_settings")
2419

2520
filegroup(
@@ -34,11 +29,6 @@ construct_config_settings(
3429
name = "construct_config_settings",
3530
default_version = DEFAULT_PYTHON_VERSION,
3631
documented_flags = [
37-
":pip_whl",
38-
":pip_whl_glibc_version",
39-
":pip_whl_muslc_version",
40-
":pip_whl_osx_arch",
41-
":pip_whl_osx_version",
4232
":py_freethreaded",
4333
":py_linux_libc",
4434
],
@@ -157,70 +147,6 @@ string_flag(
157147

158148
# pip.parse related flags
159149

160-
string_flag(
161-
name = "pip_whl",
162-
build_setting_default = UseWhlFlag.AUTO,
163-
values = sorted(UseWhlFlag.__members__.values()),
164-
# NOTE: Only public because it is used in pip hub repos.
165-
visibility = ["//visibility:public"],
166-
)
167-
168-
config_setting(
169-
name = "is_pip_whl_auto",
170-
flag_values = {
171-
":pip_whl": UseWhlFlag.AUTO,
172-
},
173-
# NOTE: Only public because it is used in pip hub repos.
174-
visibility = ["//visibility:public"],
175-
)
176-
177-
config_setting(
178-
name = "is_pip_whl_no",
179-
flag_values = {
180-
":pip_whl": UseWhlFlag.NO,
181-
},
182-
# NOTE: Only public because it is used in pip hub repos.
183-
visibility = ["//visibility:public"],
184-
)
185-
186-
config_setting(
187-
name = "is_pip_whl_only",
188-
flag_values = {
189-
":pip_whl": UseWhlFlag.ONLY,
190-
},
191-
# NOTE: Only public because it is used in pip hub repos.
192-
visibility = ["//visibility:public"],
193-
)
194-
195-
string_flag(
196-
name = "pip_whl_osx_arch",
197-
build_setting_default = UniversalWhlFlag.ARCH,
198-
values = sorted(UniversalWhlFlag.__members__.values()),
199-
# NOTE: Only public because it is used in pip hub repos.
200-
visibility = ["//visibility:public"],
201-
)
202-
203-
string_flag(
204-
name = "pip_whl_glibc_version",
205-
build_setting_default = "",
206-
# NOTE: Only public because it is used in pip hub repos.
207-
visibility = ["//visibility:public"],
208-
)
209-
210-
string_flag(
211-
name = "pip_whl_muslc_version",
212-
build_setting_default = "",
213-
# NOTE: Only public because it is used in pip hub repos.
214-
visibility = ["//visibility:public"],
215-
)
216-
217-
string_flag(
218-
name = "pip_whl_osx_version",
219-
build_setting_default = "",
220-
# NOTE: Only public because it is used in pip hub repos.
221-
visibility = ["//visibility:public"],
222-
)
223-
224150
string_flag(
225151
name = "venvs_site_packages",
226152
build_setting_default = VenvsSitePackages.NO,

python/private/common_labels.bzl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ labels = struct(
1616
EXEC_TOOLS_TOOLCHAIN = str(Label("//python/config_settings:exec_tools_toolchain")),
1717
NONE = str(Label("//python:none")),
1818
PIP_ENV_MARKER_CONFIG = str(Label("//python/config_settings:pip_env_marker_config")),
19-
PIP_WHL = str(Label("//python/config_settings:pip_whl")),
20-
PIP_WHL_GLIBC_VERSION = str(Label("//python/config_settings:pip_whl_glibc_version")),
21-
PIP_WHL_MUSLC_VERSION = str(Label("//python/config_settings:pip_whl_muslc_version")),
22-
PIP_WHL_OSX_ARCH = str(Label("//python/config_settings:pip_whl_osx_arch")),
23-
PIP_WHL_OSX_VERSION = str(Label("//python/config_settings:pip_whl_osx_version")),
2419
PLATFORMS_OS_WINDOWS = str(Label("@platforms//os:windows")),
2520
PRECOMPILE = str(Label("//python/config_settings:precompile")),
2621
PRECOMPILE_SOURCE_RETENTION = str(Label("//python/config_settings:precompile_source_retention")),

python/private/pypi/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ bzl_library(
145145
deps = [
146146
":env_marker_info.bzl",
147147
":pep508_env_bzl",
148-
"//python/private:enum_bzl",
149148
"@bazel_skylib//rules:common_settings",
150149
],
151150
)

python/private/pypi/flags.bzl

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ 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", "BuildSettingInfo", "string_flag")
21+
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
2222
load("//python/private:common_labels.bzl", "labels")
23-
load("//python/private:enum.bzl", "enum")
2423
load(":env_marker_info.bzl", "EnvMarkerInfo")
2524
load(
2625
":pep508_env.bzl",
@@ -31,87 +30,16 @@ load(
3130
"sys_platform_select_map",
3231
)
3332

34-
# Determines if we should use whls for third party
35-
#
36-
# buildifier: disable=name-conventions
37-
UseWhlFlag = enum(
38-
# Automatically decide the effective value based on environment, target
39-
# platform and the presence of distributions for a particular package.
40-
AUTO = "auto",
41-
# Do not use `sdist` and fail if there are no available whls suitable for the target platform.
42-
ONLY = "only",
43-
# Do not use whl distributions and instead build the whls from `sdist`.
44-
NO = "no",
45-
)
46-
47-
# Determines whether universal wheels should be preferred over arch platform specific ones.
48-
#
49-
# buildifier: disable=name-conventions
50-
UniversalWhlFlag = enum(
51-
# Prefer platform-specific wheels over universal wheels.
52-
ARCH = "arch",
53-
# Prefer universal wheels over platform-specific wheels.
54-
UNIVERSAL = "universal",
55-
)
56-
57-
_STRING_FLAGS = [
58-
"dist",
59-
"whl_plat",
60-
"whl_plat_py3",
61-
"whl_plat_py3_abi3",
62-
"whl_plat_pycp3x",
63-
"whl_plat_pycp3x_abi3",
64-
"whl_plat_pycp3x_abicp",
65-
"whl_py3",
66-
"whl_py3_abi3",
67-
"whl_pycp3x",
68-
"whl_pycp3x_abi3",
69-
"whl_pycp3x_abicp",
70-
]
71-
72-
INTERNAL_FLAGS = [
73-
"whl",
74-
] + _STRING_FLAGS
75-
7633
def define_pypi_internal_flags(name):
7734
"""define internal PyPI flags used in PyPI hub repository by pkg_aliases.
7835
7936
Args:
8037
name: not used
8138
"""
82-
for flag in _STRING_FLAGS:
83-
string_flag(
84-
name = "_internal_pip_" + flag,
85-
build_setting_default = "",
86-
values = [""],
87-
visibility = ["//visibility:public"],
88-
)
89-
90-
_allow_wheels_flag(
91-
name = "_internal_pip_whl",
92-
visibility = ["//visibility:public"],
93-
)
94-
9539
_default_env_marker_config(
9640
name = "_pip_env_marker_default_config",
9741
)
9842

99-
def _allow_wheels_flag_impl(ctx):
100-
input = ctx.attr._setting[BuildSettingInfo].value
101-
value = "yes" if input in ["auto", "only"] else "no"
102-
return [config_common.FeatureFlagInfo(value = value)]
103-
104-
_allow_wheels_flag = rule(
105-
implementation = _allow_wheels_flag_impl,
106-
attrs = {
107-
"_setting": attr.label(default = labels.PIP_WHL),
108-
},
109-
doc = """
110-
This rule allows us to greatly reduce the number of config setting targets at no cost even
111-
if we are duplicating some of the functionality of the `native.config_setting`.
112-
""",
113-
)
114-
11543
def _default_env_marker_config(**kwargs):
11644
_env_marker_config(
11745
os_name = select(os_name_select_map),

python/private/pypi/hub_builder.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ load("//python/private:text_util.bzl", "render")
77
load("//python/private:version.bzl", "version")
88
load("//python/private:version_label.bzl", "version_label")
99
load(":attrs.bzl", "use_isolated")
10-
load(":evaluate_markers.bzl", evaluate_markers_star = "evaluate_markers")
10+
load(":evaluate_markers.bzl", "evaluate_markers")
1111
load(":parse_requirements.bzl", "parse_requirements")
1212
load(":pep508_env.bzl", "env")
1313
load(":pep508_evaluate.bzl", "evaluate")
@@ -469,7 +469,7 @@ def _evaluate_markers(self, pip_attr):
469469
if self._evaluate_markers_fn:
470470
return self._evaluate_markers_fn
471471

472-
return lambda _, requirements: evaluate_markers_star(
472+
return lambda requirements: evaluate_markers(
473473
requirements = requirements,
474474
platforms = self._platforms[pip_attr.python_version],
475475
)

tests/pypi/config_settings/config_settings_tests.bzl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,7 @@ _subject = rule(
3232

3333
_flag = struct(
3434
platform = lambda x: ("//command_line_option:platforms", str(Label("//tests/support/platforms:" + x))),
35-
pip_whl = lambda x: (str(Label("//python/config_settings:pip_whl")), str(x)),
36-
pip_whl_glibc_version = lambda x: (str(Label("//python/config_settings:pip_whl_glibc_version")), str(x)),
37-
pip_whl_muslc_version = lambda x: (str(Label("//python/config_settings:pip_whl_muslc_version")), str(x)),
38-
pip_whl_osx_version = lambda x: (str(Label("//python/config_settings:pip_whl_osx_version")), str(x)),
39-
pip_whl_osx_arch = lambda x: (str(Label("//python/config_settings:pip_whl_osx_arch")), str(x)),
40-
py_linux_libc = lambda x: (str(Label("//python/config_settings:py_linux_libc")), str(x)),
4135
python_version = lambda x: (str(Label("//python/config_settings:python_version")), str(x)),
42-
py_freethreaded = lambda x: (str(Label("//python/config_settings:py_freethreaded")), str(x)),
4336
)
4437

4538
def _analysis_test(*, name, dist, want, config_settings = [_flag.platform("linux_aarch64")]):

0 commit comments

Comments
 (0)