Skip to content

Commit 51f1047

Browse files
authored
refactor(pypi): rename config settings and improve docs (#2556)
Before the PR the `config_setting` names where following an internal logic and those names would be leaking into the error messages when no match is found. I thought that the names thus should be improved and maybe made more similar to the `whl` filename parts that they are derived from. As part of this change I have also added more docs and added them to sphinxdocs in the hopes that this documentation helps maintainers and users looking at error messages alike. Summary: * Make names more similar to the whl filenames. * Instead of having `osx_<cpu>_universal2` config settings for each `cpu` value, have a single `osx_universal2` config setting. * Stop creating redundant/unused config settings * Refactor the `_dist_config_setting` code to be simpler and create fewer targets by using a clever trick for the `whl` config setting flag value usage. The stats: ``` $ bazel query //tests/pypi/config_settings/... | rg ":(|_)is" | wc -l 2223 $ bazel query @dev_pip//_config/... | wc -l 1982 $ bazel query //tests/pypi/config_settings/... | rg ":(|_)is" | wc -l 1780 $ bazel query @dev_pip//_config/... | wc -l 1066 ``` Work towards #260
1 parent 4db0d91 commit 51f1047

File tree

9 files changed

+474
-320
lines changed

9 files changed

+474
-320
lines changed

docs/BUILD.bazel

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ sphinx_stardocs(
103103
"//python/private:py_runtime_rule_bzl",
104104
"//python/private:py_test_rule_bzl",
105105
"//python/private/api:py_common_api_bzl",
106+
"//python/private/pypi:config_settings_bzl",
107+
"//python/private/pypi:pkg_aliases_bzl",
106108
] + ([
107109
# Bazel 6 + Stardoc isn't able to parse something about the python bzlmod extension
108110
"//python/extensions:python_bzl",

python/private/pypi/BUILD.bazel

+38-23
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,32 @@ bzl_library(
5353
srcs = ["attrs.bzl"],
5454
)
5555

56+
bzl_library(
57+
name = "config_settings_bzl",
58+
srcs = ["config_settings.bzl"],
59+
deps = [
60+
":flags_bzl",
61+
"//python/private:flags_bzl",
62+
],
63+
)
64+
65+
bzl_library(
66+
name = "deps_bzl",
67+
srcs = ["deps.bzl"],
68+
deps = [
69+
"//python/private:bazel_tools_bzl",
70+
"//python/private:glob_excludes_bzl",
71+
],
72+
)
73+
74+
bzl_library(
75+
name = "evaluate_markers_bzl",
76+
srcs = ["evaluate_markers.bzl"],
77+
deps = [
78+
":pypi_repo_utils_bzl",
79+
],
80+
)
81+
5682
bzl_library(
5783
name = "extension_bzl",
5884
srcs = ["extension.bzl"],
@@ -76,29 +102,6 @@ bzl_library(
76102
],
77103
)
78104

79-
bzl_library(
80-
name = "config_settings_bzl",
81-
srcs = ["config_settings.bzl"],
82-
deps = ["flags_bzl"],
83-
)
84-
85-
bzl_library(
86-
name = "deps_bzl",
87-
srcs = ["deps.bzl"],
88-
deps = [
89-
"//python/private:bazel_tools_bzl",
90-
"//python/private:glob_excludes_bzl",
91-
],
92-
)
93-
94-
bzl_library(
95-
name = "evaluate_markers_bzl",
96-
srcs = ["evaluate_markers.bzl"],
97-
deps = [
98-
":pypi_repo_utils_bzl",
99-
],
100-
)
101-
102105
bzl_library(
103106
name = "flags_bzl",
104107
srcs = ["flags.bzl"],
@@ -245,6 +248,18 @@ bzl_library(
245248
srcs = ["pip_repository_attrs.bzl"],
246249
)
247250

251+
bzl_library(
252+
name = "pkg_aliases_bzl",
253+
srcs = ["pkg_aliases.bzl"],
254+
deps = [
255+
":labels_bzl",
256+
":parse_whl_name_bzl",
257+
":whl_target_platforms_bzl",
258+
"//python/private:text_util_bzl",
259+
"@bazel_skylib//lib:selects",
260+
],
261+
)
262+
248263
bzl_library(
249264
name = "pypi_repo_utils_bzl",
250265
srcs = ["pypi_repo_utils.bzl"],

0 commit comments

Comments
 (0)