feat(pypi): Add extra_hub_aliases to pip_repository too (#2426)
The extra_hub_aliases feature from #2369 has bindings in the pip
extension
for bzlmod users, but not pip_repository for WORKSPACE users. But it
_can_ work for either, so this patch moves it to the list of attrs the
two share and makes it work with the latter.
---------
Co-authored-by: Ignas Anikevicius <240938+aignas@users.noreply.github.com>
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4c6a08d..f067b4f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -71,6 +71,7 @@
Other changes:
* (python_repository) Start honoring the `strip_prefix` field for `zstd` archives.
+* (pypi) {bzl:obj}`pip_parse.extra_hub_aliases` now works in WORKSPACE files.
{#v0-0-0-fixed}
### Fixed
diff --git a/examples/bzlmod/MODULE.bazel.lock b/examples/bzlmod/MODULE.bazel.lock
index 9cad595..18538d9 100644
--- a/examples/bzlmod/MODULE.bazel.lock
+++ b/examples/bzlmod/MODULE.bazel.lock
@@ -1562,7 +1562,7 @@
},
"@@rules_python~//python/extensions:pip.bzl%pip": {
"general": {
- "bzlTransitiveDigest": "i5dWUNj1rZ4NKXmzLiGceV+1gAsDWtpJED1w1tdB7WY=",
+ "bzlTransitiveDigest": "c3HURsyNEdAN0fRo5BXiCkhhZSPfl1zNBcQOQbpgJ64=",
"usagesDigest": "VmrNvB/4EhzsYieLDka9584M+pYKPpjNLl3Wcb5rx/c=",
"recordedFileInputs": {
"@@//requirements_lock_3_10.txt": "5e7083982a7e60f34998579a0ae83b520d46ab8f2552cc51337217f024e6def5",
@@ -7035,7 +7035,7 @@
},
"@@rules_python~//python/private/pypi:pip.bzl%pip_internal": {
"general": {
- "bzlTransitiveDigest": "ltVKFX5LXgwSpZtjuyF02xZspYIWHEFmpxmzvnyMbQ8=",
+ "bzlTransitiveDigest": "H9pnwH6wHRp4Xy2CN6NSo0mDMHFDvpqspLNW6Xbqnhc=",
"usagesDigest": "/lZXl/ZgP+u5PE8WkeWTyYBsvX9XQWFn1antj5qrBzQ=",
"recordedFileInputs": {
"@@rules_python~//tools/publish/requirements_linux.txt": "8175b4c8df50ae2f22d1706961884beeb54e7da27bd2447018314a175981997d",
diff --git a/python/private/pypi/attrs.bzl b/python/private/pypi/attrs.bzl
index c6132cb..c9b7ea6 100644
--- a/python/private/pypi/attrs.bzl
+++ b/python/private/pypi/attrs.bzl
@@ -141,6 +141,16 @@
NOTE: this is not for cross-compiling Python wheels but rather for parsing the `whl` METADATA correctly.
""",
),
+ "extra_hub_aliases": attr.string_list_dict(
+ doc = """\
+Extra aliases to make for specific wheels in the hub repo. This is useful when
+paired with the {attr}`whl_modifications`.
+
+:::{versionadded} 0.38.0
+:::
+""",
+ mandatory = False,
+ ),
"extra_pip_args": attr.string_list(
doc = """Extra arguments to pass on to pip. Must not contain spaces.
diff --git a/python/private/pypi/extension.bzl b/python/private/pypi/extension.bzl
index ea2bafd..3df7b52 100644
--- a/python/private/pypi/extension.bzl
+++ b/python/private/pypi/extension.bzl
@@ -750,16 +750,6 @@
https://packaging.python.org/en/latest/specifications/simple-repository-api/
""",
),
- "extra_hub_aliases": attr.string_list_dict(
- doc = """\
-Extra aliases to make for specific wheels in the hub repo. This is useful when
-paired with the {attr}`whl_modifications`.
-
-:::{versionadded} 0.38.0
-:::
-""",
- mandatory = False,
- ),
"hub_name": attr.string(
mandatory = True,
doc = """
diff --git a/python/private/pypi/pip_repository.bzl b/python/private/pypi/pip_repository.bzl
index 90cda77..597b37f 100644
--- a/python/private/pypi/pip_repository.bzl
+++ b/python/private/pypi/pip_repository.bzl
@@ -177,6 +177,7 @@
pkg: [whl_alias(repo = rctx.attr.name + "_" + pkg)]
for pkg in bzl_packages or []
},
+ extra_hub_aliases = rctx.attr.extra_hub_aliases,
)
for path, contents in aliases.items():
rctx.file(path, contents)