@@ -47,12 +47,18 @@ def hub_builder(
4747 _simpleapi_download_fn = simpleapi_download_fn ,
4848 _simpleapi_cache = simpleapi_cache ,
4949 _get_index_urls = {},
50+ _pip_attrs = {},
51+ _use_downloader = {},
5052 # keep sorted
5153 add = lambda * a , ** k : _add (self , * a , ** k ),
5254 detect_interpreter = lambda * a , ** k : _detect_interpreter (self , * a , ** k ),
53- get_index_urls = lambda version : self ._get_index_urls [ version ] ,
55+ get_index_urls = lambda version : self ._get_index_urls . get ( version ) ,
5456 platforms = lambda version : self .python_versions [version ],
5557 add_whl_library = lambda * a , ** k : _add_whl_library (self , * a , ** k ),
58+ use_downloader = lambda python_version , whl_name : self ._use_downloader .get (python_version , {}).get (
59+ normalize_name (whl_name ),
60+ python_version in self ._get_index_urls ,
61+ ),
5662 )
5763
5864 # buildifier: enable=uninitialized
@@ -76,22 +82,32 @@ def _add(self, *, pip_attr):
7682 minor_mapping = self ._minor_mapping ,
7783 config = self .config ,
7884 )
79- self ._get_index_urls [python_version ] = _get_index_urls (self , pip_attr )
85+ _set_index_urls (self , pip_attr )
86+ self ._pip_attrs [python_version ] = pip_attr
8087
81- def _get_index_urls (self , pip_attr ):
88+ def _set_index_urls (self , pip_attr ):
8289 if not pip_attr .experimental_index_url :
8390 if pip_attr .experimental_extra_index_urls :
8491 fail ("'experimental_extra_index_urls' is a no-op unless 'experimental_index_url' is set" )
8592 elif pip_attr .experimental_index_url_overrides :
8693 fail ("'experimental_index_url_overrides' is a no-op unless 'experimental_index_url' is set" )
94+ elif pip_attr .simpleapi_skip :
95+ fail ("'simpleapi_skip' is a no-op unless 'experimental_index_url' is set" )
96+ elif pip_attr .netrc :
97+ fail ("'netrc' is a no-op unless 'experimental_index_url' is set" )
98+ elif pip_attr .auth_patterns :
99+ fail ("'auth_patterns' is a no-op unless 'experimental_index_url' is set" )
100+
101+ # parallel_download is set to True by default, so we are not checking/validating it
102+ # here
103+ return
87104
88- return None
89-
90- skip_sources = [
91- normalize_name (s )
105+ python_version = pip_attr .python_version
106+ self ._use_downloader .setdefault (python_version , {}).update ({
107+ normalize_name (s ): False
92108 for s in pip_attr .simpleapi_skip
93- ]
94- return lambda ctx , distributions : self ._simpleapi_download_fn (
109+ })
110+ self . _get_index_urls [ python_version ] = lambda ctx , distributions : self ._simpleapi_download_fn (
95111 ctx ,
96112 attr = struct (
97113 index_url = pip_attr .experimental_index_url ,
@@ -100,7 +116,7 @@ def _get_index_urls(self, pip_attr):
100116 sources = [
101117 d
102118 for d in distributions
103- if normalize_name ( d ) not in skip_sources
119+ if self . use_downloader ( python_version , d )
104120 ],
105121 envsubst = pip_attr .envsubst ,
106122 # Auth related info
0 commit comments