Skip to content

Commit

Permalink
refactor(pypi): rename config settings and improve docs (#2556)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
aignas authored Jan 12, 2025
1 parent 4db0d91 commit 51f1047
Show file tree
Hide file tree
Showing 9 changed files with 474 additions and 320 deletions.
2 changes: 2 additions & 0 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ sphinx_stardocs(
"//python/private:py_runtime_rule_bzl",
"//python/private:py_test_rule_bzl",
"//python/private/api:py_common_api_bzl",
"//python/private/pypi:config_settings_bzl",
"//python/private/pypi:pkg_aliases_bzl",
] + ([
# Bazel 6 + Stardoc isn't able to parse something about the python bzlmod extension
"//python/extensions:python_bzl",
Expand Down
61 changes: 38 additions & 23 deletions python/private/pypi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,32 @@ bzl_library(
srcs = ["attrs.bzl"],
)

bzl_library(
name = "config_settings_bzl",
srcs = ["config_settings.bzl"],
deps = [
":flags_bzl",
"//python/private:flags_bzl",
],
)

bzl_library(
name = "deps_bzl",
srcs = ["deps.bzl"],
deps = [
"//python/private:bazel_tools_bzl",
"//python/private:glob_excludes_bzl",
],
)

bzl_library(
name = "evaluate_markers_bzl",
srcs = ["evaluate_markers.bzl"],
deps = [
":pypi_repo_utils_bzl",
],
)

bzl_library(
name = "extension_bzl",
srcs = ["extension.bzl"],
Expand All @@ -76,29 +102,6 @@ bzl_library(
],
)

bzl_library(
name = "config_settings_bzl",
srcs = ["config_settings.bzl"],
deps = ["flags_bzl"],
)

bzl_library(
name = "deps_bzl",
srcs = ["deps.bzl"],
deps = [
"//python/private:bazel_tools_bzl",
"//python/private:glob_excludes_bzl",
],
)

bzl_library(
name = "evaluate_markers_bzl",
srcs = ["evaluate_markers.bzl"],
deps = [
":pypi_repo_utils_bzl",
],
)

bzl_library(
name = "flags_bzl",
srcs = ["flags.bzl"],
Expand Down Expand Up @@ -245,6 +248,18 @@ bzl_library(
srcs = ["pip_repository_attrs.bzl"],
)

bzl_library(
name = "pkg_aliases_bzl",
srcs = ["pkg_aliases.bzl"],
deps = [
":labels_bzl",
":parse_whl_name_bzl",
":whl_target_platforms_bzl",
"//python/private:text_util_bzl",
"@bazel_skylib//lib:selects",
],
)

bzl_library(
name = "pypi_repo_utils_bzl",
srcs = ["pypi_repo_utils.bzl"],
Expand Down
Loading

0 comments on commit 51f1047

Please sign in to comment.