Skip to content

feat(pypi): allow scoping pip.override to single hubs #2813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions python/private/pypi/extension.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ def _create_whl_repos(
python_interpreter_target = python_interpreter_target,
whl_patches = {
p: json.encode(args)
for p, args in whl_overrides.get(whl_name, {}).items()
for p, args in (
whl_overrides.get(hub_name, {}).get(whl_name, {}).items() +
whl_overrides.get("", {}).get(whl_name, {}).items() # Overrides without a hub name apply to all hubs
)
},
)
whl_library_args.update({k: v for k, v in maybe_args.items() if v})
Expand Down Expand Up @@ -384,16 +387,18 @@ You cannot use both the additive_build_content and additive_build_content_file a
_overriden_whl_set[attr.file] = None

for patch in attr.patches:
if whl_name not in whl_overrides:
whl_overrides[whl_name] = {}
if attr.hub_name not in whl_overrides:
whl_overrides[attr.hub_name] = {}
if whl_name not in whl_overrides[attr.hub_name]:
whl_overrides[attr.hub_name][whl_name] = {}

if patch not in whl_overrides[whl_name]:
whl_overrides[whl_name][patch] = struct(
if patch not in whl_overrides[attr.hub_name][whl_name]:
whl_overrides[attr.hub_name][whl_name][patch] = struct(
patch_strip = attr.patch_strip,
whls = [],
)

whl_overrides[whl_name][patch].whls.append(attr.file)
whl_overrides[attr.hub_name][whl_name][patch].whls.append(attr.file)

# Used to track all the different pip hubs and the spoke pip Python
# versions.
Expand Down Expand Up @@ -845,6 +850,12 @@ applied to all repositories that setup this distribution via the pip.parse tag
class.""",
mandatory = True,
),
"hub_name": attr.string(
doc = """
The name of the pip repo to override the wheel in. If this is not provided the
wheel is overridden in all pip hubs.
""",
),
"patch_strip": attr.int(
default = 0,
doc = """\
Expand Down