@@ -31,9 +31,7 @@ load(":hub_repository.bzl", "hub_repository", "whl_config_settings_to_json")
3131load (":parse_requirements.bzl" , "parse_requirements" )
3232load (":parse_whl_name.bzl" , "parse_whl_name" )
3333load (":pep508_env.bzl" , "env" )
34- load (":pep508_evaluate.bzl" , "evaluate" )
3534load (":pip_repository_attrs.bzl" , "ATTRS" )
36- load (":python_tag.bzl" , "python_tag" )
3735load (":requirements_files_by_platform.bzl" , "requirements_files_by_platform" )
3836load (":simpleapi_download.bzl" , "simpleapi_download" )
3937load (":whl_config_setting.bzl" , "whl_config_setting" )
@@ -69,57 +67,11 @@ def _whl_mods_impl(whl_mods_dict):
6967 whl_mods = whl_mods ,
7068 )
7169
72- def _platforms (* , python_version , minor_mapping , config ):
73- platforms = {}
74- python_version = version .parse (
75- full_version (
76- version = python_version ,
77- minor_mapping = minor_mapping ,
78- ),
79- strict = True ,
80- )
81-
82- for platform , values in config .platforms .items ():
83- # TODO @aignas 2025-07-07: this is probably doing the parsing of the version too
84- # many times.
85- abi = "{}{}{}.{}" .format (
86- python_tag (values .env ["implementation_name" ]),
87- python_version .release [0 ],
88- python_version .release [1 ],
89- python_version .release [2 ],
90- )
91- key = "{}_{}" .format (abi , platform )
92-
93- env_ = env (
94- env = values .env ,
95- os = values .os_name ,
96- arch = values .arch_name ,
97- python_version = python_version .string ,
98- )
99-
100- if values .marker and not evaluate (values .marker , env = env_ ):
101- continue
102-
103- platforms [key ] = struct (
104- env = env_ ,
105- triple = "{}_{}_{}" .format (abi , values .os_name , values .arch_name ),
106- whl_abi_tags = [
107- v .format (
108- major = python_version .release [0 ],
109- minor = python_version .release [1 ],
110- )
111- for v in values .whl_abi_tags
112- ],
113- whl_platform_tags = values .whl_platform_tags ,
114- )
115- return platforms
116-
11770def _create_whl_repos (
11871 module_ctx ,
11972 * ,
12073 pip_attr ,
12174 whl_overrides ,
122- config ,
12375 hub ,
12476 minor_mapping = MINOR_MAPPING ,
12577 evaluate_markers = None ):
@@ -130,7 +82,6 @@ def _create_whl_repos(
13082 pip_attr: {type}`struct` - the struct that comes from the tag class iteration.
13183 whl_overrides: {type}`dict[str, struct]` - per-wheel overrides.
13284 hub: TODO.
133- config: The platform configuration.
13485 minor_mapping: {type}`dict[str, str]` The dictionary needed to resolve the full
13586 python version used to parse package METADATA files.
13687 evaluate_markers: the function used to evaluate the markers.
@@ -185,16 +136,12 @@ def _create_whl_repos(
185136 whl_group_mapping = {}
186137 requirement_cycles = {}
187138
188- platforms = _platforms (
189- python_version = pip_attr .python_version ,
190- minor_mapping = minor_mapping ,
191- config = config ,
192- )
139+ platforms = hub .platforms (pip_attr .python_version )
193140
194141 if evaluate_markers :
195142 # This is most likely unit tests
196143 pass
197- elif config .enable_pipstar :
144+ elif hub . config .enable_pipstar :
198145 evaluate_markers = lambda _ , requirements : evaluate_markers_star (
199146 requirements = requirements ,
200147 platforms = platforms ,
@@ -287,7 +234,7 @@ def _create_whl_repos(
287234 for p , args in whl_overrides .get (whl .name , {}).items ()
288235 },
289236 )
290- if not config .enable_pipstar :
237+ if not hub . config .enable_pipstar :
291238 maybe_args ["experimental_target_platforms" ] = pip_attr .experimental_target_platforms
292239
293240 whl_library_args .update ({k : v for k , v in maybe_args .items () if v })
@@ -308,15 +255,15 @@ def _create_whl_repos(
308255 src = src ,
309256 whl_library_args = whl_library_args ,
310257 download_only = pip_attr .download_only ,
311- netrc = config .netrc or pip_attr .netrc ,
258+ netrc = hub . config .netrc or pip_attr .netrc ,
312259 use_downloader = use_downloader .get (
313260 whl .name ,
314261 get_index_urls != None , # defaults to True if the get_index_urls is defined
315262 ),
316- auth_patterns = config .auth_patterns or pip_attr .auth_patterns ,
263+ auth_patterns = hub . config .auth_patterns or pip_attr .auth_patterns ,
317264 python_version = _major_minor_version (pip_attr .python_version ),
318265 is_multiple_versions = whl .is_multiple_versions ,
319- enable_pipstar = config .enable_pipstar ,
266+ enable_pipstar = hub . config .enable_pipstar ,
320267 )
321268 if repo == None :
322269 # NOTE @aignas 2025-07-07: we guard against an edge-case where there
@@ -332,7 +279,7 @@ def _create_whl_repos(
332279 ))
333280 whl_libraries [repo_name ] = repo .args
334281
335- if not config .enable_pipstar and "experimental_target_platforms" in repo .args :
282+ if not hub . config .enable_pipstar and "experimental_target_platforms" in repo .args :
336283 whl_libraries [repo_name ] |= {
337284 "experimental_target_platforms" : sorted ({
338285 # TODO @aignas 2025-07-07: this should be solved in a better way
@@ -636,6 +583,7 @@ You cannot use both the additive_build_content and additive_build_content_file a
636583 builder = hub_builder (
637584 name = hub_name ,
638585 module_name = mod .name ,
586+ config = config ,
639587 simpleapi_download_fn = simpleapi_download ,
640588 simpleapi_cache = simpleapi_cache ,
641589 minor_mapping = kwargs .get ("minor_mapping" , MINOR_MAPPING ),
@@ -669,9 +617,9 @@ You cannot use both the additive_build_content and additive_build_content_file a
669617 hub = builder ,
670618 pip_attr = pip_attr ,
671619 whl_overrides = whl_overrides ,
672- config = config ,
673620 ** kwargs
674621 )
622+
675623 hub_whl_map .setdefault (hub_name , {})
676624 for key , settings in out .whl_map .items ():
677625 for setting , repo in settings .items ():
0 commit comments