@@ -66,7 +66,7 @@ def _whl_mods_impl(whl_mods_dict):
6666 whl_mods = whl_mods ,
6767 )
6868
69- def _create_whl_repos (
69+ def _add_whl_repos (
7070 module_ctx ,
7171 * ,
7272 pip_attr ,
@@ -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 )
@@ -126,6 +115,7 @@ def _create_whl_repos(
126115 logger = logger ,
127116 )
128117
118+ exposed_packages = {}
129119 if pip_attr .experimental_requirement_cycles :
130120 requirement_cycles = {
131121 name : [normalize_name (whl_name ) for whl_name in whls ]
@@ -140,7 +130,6 @@ def _create_whl_repos(
140130 else :
141131 whl_group_mapping = {}
142132 requirement_cycles = {}
143- exposed_packages = {}
144133 for whl in requirements_by_platform :
145134 if whl .is_exposed :
146135 exposed_packages [whl .name ] = None
@@ -205,13 +194,17 @@ def _create_whl_repos(
205194 repo = repo ,
206195 )
207196
208- return struct (
209- exposed_packages = exposed_packages ,
210- extra_aliases = {
211- whl_name : {alias : True for alias in aliases }
212- for whl_name , aliases in pip_attr .extra_hub_aliases .items ()
213- },
214- )
197+ if not hub .exposed_packages :
198+ hub .exposed_packages .update (exposed_packages )
199+ else :
200+ intersection = {}
201+ for pkg in exposed_packages :
202+ if pkg not in hub .exposed_packages :
203+ continue
204+ intersection [pkg ] = None
205+
206+ hub .exposed_packages .clear ()
207+ hub .exposed_packages .update (intersection )
215208
216209def _whl_repo (
217210 * ,
@@ -516,40 +509,23 @@ You cannot use both the additive_build_content and additive_build_content_file a
516509 builder .add (pip_attr = pip_attr )
517510
518511 # TODO @aignas 2025-05-19: express pip.parse as a series of configure calls
519- out = _create_whl_repos (
512+ _add_whl_repos (
520513 module_ctx ,
521514 hub = builder ,
522515 pip_attr = pip_attr ,
523516 whl_overrides = whl_overrides ,
524517 minor_mapping = kwargs .get ("minor_mapping" , MINOR_MAPPING ),
525518 )
526519
527- extra_aliases .setdefault (hub_name , {})
528- for whl_name , aliases in out .extra_aliases .items ():
529- extra_aliases [hub_name ].setdefault (whl_name , {}).update (aliases )
530-
531- if hub_name not in exposed_packages :
532- exposed_packages [hub_name ] = out .exposed_packages
533- else :
534- intersection = {}
535- for pkg in out .exposed_packages :
536- if pkg not in exposed_packages [hub_name ]:
537- continue
538- intersection [pkg ] = None
539- exposed_packages [hub_name ] = intersection
540-
541- # TODO @aignas 2024-04-05: how do we support different requirement
542- # cycles for different abis/oses? For now we will need the users to
543- # assume the same groups across all versions/platforms until we start
544- # using an alternative cycle resolution strategy.
545- hub_group_map [hub_name ] = pip_attr .experimental_requirement_cycles
546-
547520 for hub in pip_hub_map .values ():
548521 hub_whl_map .setdefault (hub .name , {})
549522 for key , settings in hub .whl_map .items ():
550523 for setting , repo in settings .items ():
551524 hub_whl_map [hub .name ].setdefault (key , {}).setdefault (repo , []).append (setting )
552525
526+ for whl_name , aliases in hub .extra_aliases .items ():
527+ extra_aliases [hub .name ].setdefault (whl_name , {}).update (aliases )
528+
553529 whl_libraries .update (hub .whl_libraries )
554530 for whl_name , lib in hub .whl_libraries .items ():
555531 if whl_name in lib :
@@ -558,6 +534,9 @@ You cannot use both the additive_build_content and additive_build_content_file a
558534 # replicate whl_libraries.update(out.whl_libraries)
559535 whl_libraries [whl_name ] = lib
560536
537+ hub_group_map [hub .name ] = hub .group_map
538+ exposed_packages [hub .name ] = hub .exposed_packages
539+
561540 return struct (
562541 # We sort so that the lock-file remains the same no matter the order of how the
563542 # args are manipulated in the code going before.
0 commit comments