@@ -50,7 +50,7 @@ def hub_builder(
5050 self = struct (
5151 name = name ,
5252 module_name = module_name ,
53- python_versions = {},
53+ _platforms = {},
5454 config = config ,
5555 whl_map = {},
5656 exposed_packages = {},
@@ -64,21 +64,14 @@ def hub_builder(
6464 _simpleapi_download_fn = simpleapi_download_fn ,
6565 _simpleapi_cache = simpleapi_cache ,
6666 _get_index_urls = {},
67- _pip_attrs = {},
6867 _use_downloader = {},
6968 # keep sorted
70- add = lambda * a , ** k : _add (self , * a , ** k ),
71- detect_interpreter = lambda * a , ** k : _detect_interpreter (self , * a , ** k ),
7269 get_index_urls = lambda version : self ._get_index_urls .get (version ),
73- platforms = lambda version : self .python_versions [version ],
74- add_whl_library = lambda * a , ** k : _add_whl_library (self , * a , ** k ),
7570 use_downloader = lambda python_version , whl_name : self ._use_downloader .get (python_version , {}).get (
7671 normalize_name (whl_name ),
77- python_version in self . _get_index_urls ,
72+ self . get_index_urls ( python_version ) != None ,
7873 ),
79- evaluate_markers = lambda * a , ** k : _evaluate_markers (self , * a , ** k ),
8074 build = lambda : _build (self ),
81- create_whl_repos = lambda * a , ** k : _create_whl_repos (self , * a , ** k ),
8275 pip_parse = lambda * a , ** k : _pip_parse (self , * a , ** k ),
8376 )
8477
@@ -102,39 +95,6 @@ def _build(self):
10295 whl_libraries = self .whl_libraries ,
10396 )
10497
105- def _add (self , * , pip_attr ):
106- python_version = pip_attr .python_version
107- if python_version in self .python_versions :
108- fail ((
109- "Duplicate pip python version '{version}' for hub " +
110- "'{hub}' in module '{module}': the Python versions " +
111- "used for a hub must be unique"
112- ).format (
113- hub = self .name ,
114- module = self .module_name ,
115- version = python_version ,
116- ))
117-
118- self .python_versions [python_version ] = _platforms (
119- python_version = python_version ,
120- minor_mapping = self ._minor_mapping ,
121- config = self .config ,
122- )
123- _set_index_urls (self , pip_attr )
124- self ._pip_attrs [python_version ] = pip_attr
125-
126- # TODO @aignas 2024-04-05: how do we support different requirement
127- # cycles for different abis/oses? For now we will need the users to
128- # assume the same groups across all versions/platforms until we start
129- # using an alternative cycle resolution strategy.
130- self .group_map .clear ()
131- self .group_map .update (pip_attr .experimental_requirement_cycles )
132-
133- for whl_name , aliases in pip_attr .extra_hub_aliases .items ():
134- self .extra_aliases .setdefault (whl_name , {}).update (
135- {alias : True for alias in aliases },
136- )
137-
13898def _set_index_urls (self , pip_attr ):
13999 if not pip_attr .experimental_index_url :
140100 if pip_attr .experimental_extra_index_urls :
@@ -254,7 +214,7 @@ def _add_whl_library(self, *, python_version, whl, repo):
254214 # disallow building from sdist.
255215 return
256216
257- platforms = self .python_versions [python_version ]
217+ platforms = self ._platforms [python_version ]
258218
259219 # TODO @aignas 2025-06-29: we should not need the version in the repo_name if
260220 # we are using pipstar and we are downloading the wheel using the downloader
@@ -297,10 +257,10 @@ def _evaluate_markers(self, pip_attr):
297257 if self .config .enable_pipstar :
298258 return lambda _ , requirements : evaluate_markers_star (
299259 requirements = requirements ,
300- platforms = self .python_versions [pip_attr .python_version ],
260+ platforms = self ._platforms [pip_attr .python_version ],
301261 )
302262
303- interpreter = self . detect_interpreter ( pip_attr )
263+ interpreter = _detect_interpreter ( self , pip_attr )
304264
305265 # NOTE @aignas 2024-08-02: , we will execute any interpreter that we find either
306266 # in the PATH or if specified as a label. We will configure the env
@@ -320,7 +280,7 @@ def _evaluate_markers(self, pip_attr):
320280 module_ctx ,
321281 requirements = {
322282 k : {
323- p : self .python_versions [pip_attr .python_version ][p ].triple
283+ p : self ._platforms [pip_attr .python_version ][p ].triple
324284 for p in plats
325285 }
326286 for k , plats in requirements .items ()
@@ -346,7 +306,7 @@ def _create_whl_repos(
346306 whl_overrides: {type}`dict[str, struct]` - per-wheel overrides.
347307 """
348308 logger = self ._logger
349- platforms = self .platforms ( pip_attr .python_version )
309+ platforms = self ._platforms [ pip_attr .python_version ]
350310 requirements_by_platform = parse_requirements (
351311 module_ctx ,
352312 requirements_by_platform = requirements_files_by_platform (
@@ -366,7 +326,7 @@ def _create_whl_repos(
366326 platforms = platforms ,
367327 extra_pip_args = pip_attr .extra_pip_args ,
368328 get_index_urls = self .get_index_urls (pip_attr .python_version ),
369- evaluate_markers = self . evaluate_markers ( pip_attr ),
329+ evaluate_markers = _evaluate_markers ( self , pip_attr ),
370330 logger = logger ,
371331 )
372332
@@ -390,7 +350,7 @@ def _create_whl_repos(
390350 whl_group_mapping = {}
391351 requirement_cycles = {}
392352
393- interpreter = self . detect_interpreter ( pip_attr )
353+ interpreter = _detect_interpreter ( self , pip_attr )
394354 exposed_packages = {}
395355 for whl in requirements_by_platform :
396356 if whl .is_exposed :
@@ -450,7 +410,8 @@ def _create_whl_repos(
450410 is_multiple_versions = whl .is_multiple_versions ,
451411 enable_pipstar = self .config .enable_pipstar ,
452412 )
453- self .add_whl_library (
413+ _add_whl_library (
414+ self ,
454415 python_version = pip_attr .python_version ,
455416 whl = whl ,
456417 repo = repo ,
@@ -539,9 +500,38 @@ def _whl_repo(
539500 )
540501
541502def _pip_parse (self , module_ctx , pip_attr , whl_overrides ):
542- self .add (pip_attr = pip_attr )
503+ python_version = pip_attr .python_version
504+ if python_version in self ._platforms :
505+ fail ((
506+ "Duplicate pip python version '{version}' for hub " +
507+ "'{hub}' in module '{module}': the Python versions " +
508+ "used for a hub must be unique"
509+ ).format (
510+ hub = self .name ,
511+ module = self .module_name ,
512+ version = python_version ,
513+ ))
514+
515+ self ._platforms [python_version ] = _platforms (
516+ python_version = python_version ,
517+ minor_mapping = self ._minor_mapping ,
518+ config = self .config ,
519+ )
520+ _set_index_urls (self , pip_attr )
521+
522+ # TODO @aignas 2024-04-05: how do we support different requirement
523+ # cycles for different abis/oses? For now we will need the users to
524+ # assume the same groups across all versions/platforms until we start
525+ # using an alternative cycle resolution strategy.
526+ self .group_map .clear ()
527+ self .group_map .update (pip_attr .experimental_requirement_cycles )
543528
544- self .create_whl_repos (
529+ for whl_name , aliases in pip_attr .extra_hub_aliases .items ():
530+ self .extra_aliases .setdefault (whl_name , {}).update (
531+ {alias : True for alias in aliases },
532+ )
533+ _create_whl_repos (
534+ self ,
545535 module_ctx ,
546536 pip_attr = pip_attr ,
547537 whl_overrides = whl_overrides ,
0 commit comments