Skip to content

Commit a636ca6

Browse files
committed
refactor: move exposed_packages to the hub builder
1 parent 7f7f635 commit a636ca6

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

python/private/pypi/extension.bzl

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,6 @@ def _create_whl_repos(
8282
hub: TODO.
8383
minor_mapping: {type}`dict[str, str]` The dictionary needed to resolve the full
8484
python version used to parse package METADATA files.
85-
86-
Returns a {type}`struct` with the following attributes:
87-
whl_map: {type}`dict[str, list[struct]]` the output is keyed by the
88-
normalized package name and the values are the instances of the
89-
{bzl:obj}`whl_config_setting` return values.
90-
exposed_packages: {type}`dict[str, Any]` this is just a way to
91-
represent a set of string values.
92-
whl_libraries: {type}`dict[str, dict[str, Any]]` the keys are the
93-
aparent repository names for the hub repo and the values are the
94-
arguments that will be passed to {bzl:obj}`whl_library` repository
95-
rule.
9685
"""
9786
logger = repo_utils.logger(module_ctx, "pypi:create_whl_repos")
9887
interpreter = hub.detect_interpreter(pip_attr)
@@ -205,9 +194,16 @@ def _create_whl_repos(
205194
repo = repo,
206195
)
207196

208-
return struct(
209-
exposed_packages = exposed_packages,
210-
)
197+
if hub.exposed_packages:
198+
intersection = {}
199+
for pkg in exposed_packages:
200+
if pkg not in hub.exposed_packages:
201+
continue
202+
intersection[pkg] = None
203+
hub.exposed_packages.clear()
204+
exposed_packages = intersection
205+
206+
hub.exposed_packages.update(exposed_packages)
211207

212208
def _whl_repo(
213209
*,
@@ -512,24 +508,14 @@ You cannot use both the additive_build_content and additive_build_content_file a
512508
builder.add(pip_attr = pip_attr)
513509

514510
# TODO @aignas 2025-05-19: express pip.parse as a series of configure calls
515-
out = _create_whl_repos(
511+
_create_whl_repos(
516512
module_ctx,
517513
hub = builder,
518514
pip_attr = pip_attr,
519515
whl_overrides = whl_overrides,
520516
minor_mapping = kwargs.get("minor_mapping", MINOR_MAPPING),
521517
)
522518

523-
if hub_name not in exposed_packages:
524-
exposed_packages[hub_name] = out.exposed_packages
525-
else:
526-
intersection = {}
527-
for pkg in out.exposed_packages:
528-
if pkg not in exposed_packages[hub_name]:
529-
continue
530-
intersection[pkg] = None
531-
exposed_packages[hub_name] = intersection
532-
533519
for hub in pip_hub_map.values():
534520
hub_whl_map.setdefault(hub.name, {})
535521
for key, settings in hub.whl_map.items():
@@ -546,6 +532,7 @@ You cannot use both the additive_build_content and additive_build_content_file a
546532

547533
hub_group_map[hub.name] = hub.group_map
548534
extra_aliases[hub.name] = hub.extra_aliases
535+
exposed_packages[hub.name] = hub.exposed_packages
549536

550537
return struct(
551538
# We sort so that the lock-file remains the same no matter the order of how the

0 commit comments

Comments
 (0)