@@ -105,7 +105,6 @@ def _create_whl_repos(
105
105
106
106
# containers to aggregate outputs from this function
107
107
whl_map = {}
108
- exposed_packages = {}
109
108
extra_aliases = {
110
109
whl_name : {alias : True for alias in aliases }
111
110
for whl_name , aliases in pip_attr .extra_hub_aliases .items ()
@@ -219,8 +218,6 @@ def _create_whl_repos(
219
218
)
220
219
221
220
for whl_name , requirements in requirements_by_platform .items ():
222
- whl_name = normalize_name (whl_name )
223
-
224
221
group_name = whl_group_mapping .get (whl_name )
225
222
group_deps = requirement_cycles .get (group_name , [])
226
223
@@ -261,68 +258,55 @@ def _create_whl_repos(
261
258
if v != default
262
259
})
263
260
264
- is_exposed = False
265
- if get_index_urls :
266
- # TODO @aignas 2024-05-26: move to a separate function
267
- found_something = False
268
- for requirement in requirements :
269
- is_exposed = is_exposed or requirement .is_exposed
270
- dists = requirement .whls
271
- if not pip_attr .download_only and requirement .sdist :
272
- dists = dists + [requirement .sdist ]
273
-
274
- for distribution in dists :
275
- found_something = True
276
- is_reproducible = False
277
-
278
- args = dict (whl_library_args )
279
- if pip_attr .netrc :
280
- args ["netrc" ] = pip_attr .netrc
281
- if pip_attr .auth_patterns :
282
- args ["auth_patterns" ] = pip_attr .auth_patterns
283
-
284
- if not distribution .filename .endswith (".whl" ):
285
- # pip is not used to download wheels and the python
286
- # `whl_library` helpers are only extracting things, however
287
- # for sdists, they will be built by `pip`, so we still
288
- # need to pass the extra args there.
289
- args ["extra_pip_args" ] = requirement .extra_pip_args
290
-
291
- # This is no-op because pip is not used to download the wheel.
292
- args .pop ("download_only" , None )
293
-
294
- repo_name = whl_repo_name (pip_name , distribution .filename , distribution .sha256 )
295
- args ["requirement" ] = requirement .srcs .requirement
296
- args ["urls" ] = [distribution .url ]
297
- args ["sha256" ] = distribution .sha256
298
- args ["filename" ] = distribution .filename
299
- args ["experimental_target_platforms" ] = requirement .target_platforms
300
-
301
- # Pure python wheels or sdists may need to have a platform here
302
- target_platforms = None
303
- if distribution .filename .endswith ("-any.whl" ) or not distribution .filename .endswith (".whl" ):
304
- if len (requirements ) > 1 :
305
- target_platforms = requirement .target_platforms
306
-
307
- whl_libraries [repo_name ] = args
308
-
309
- whl_map .setdefault (whl_name , {})[whl_config_setting (
310
- version = major_minor ,
311
- filename = distribution .filename ,
312
- target_platforms = target_platforms ,
313
- )] = repo_name
314
-
315
- if found_something :
316
- if is_exposed :
317
- exposed_packages [whl_name ] = None
318
- continue
319
-
320
- is_exposed = False
261
+ # TODO @aignas 2024-05-26: move to a separate function
321
262
for requirement in requirements :
322
- is_exposed = is_exposed or requirement .is_exposed
323
- if get_index_urls :
324
- logger .warn (lambda : "falling back to pip for installing the right file for {}" .format (requirement .srcs .requirement_line ))
263
+ dists = requirement .whls
264
+ if not pip_attr .download_only and requirement .sdist :
265
+ dists = dists + [requirement .sdist ]
266
+
267
+ for distribution in dists :
268
+ args = dict (whl_library_args )
269
+ if pip_attr .netrc :
270
+ args ["netrc" ] = pip_attr .netrc
271
+ if pip_attr .auth_patterns :
272
+ args ["auth_patterns" ] = pip_attr .auth_patterns
273
+
274
+ if not distribution .filename .endswith (".whl" ):
275
+ # pip is not used to download wheels and the python
276
+ # `whl_library` helpers are only extracting things, however
277
+ # for sdists, they will be built by `pip`, so we still
278
+ # need to pass the extra args there.
279
+ args ["extra_pip_args" ] = requirement .extra_pip_args
280
+
281
+ # This is no-op because pip is not used to download the wheel.
282
+ args .pop ("download_only" , None )
283
+
284
+ repo_name = whl_repo_name (pip_name , distribution .filename , distribution .sha256 )
285
+ args ["requirement" ] = requirement .srcs .requirement
286
+ args ["urls" ] = [distribution .url ]
287
+ args ["sha256" ] = distribution .sha256
288
+ args ["filename" ] = distribution .filename
289
+ args ["experimental_target_platforms" ] = requirement .target_platforms
290
+
291
+ # Pure python wheels or sdists may need to have a platform here
292
+ target_platforms = None
293
+ if distribution .filename .endswith ("-any.whl" ) or not distribution .filename .endswith (".whl" ):
294
+ if len (requirements ) > 1 :
295
+ target_platforms = requirement .target_platforms
296
+
297
+ whl_libraries [repo_name ] = args
298
+
299
+ whl_map .setdefault (whl_name , {})[whl_config_setting (
300
+ version = major_minor ,
301
+ filename = distribution .filename ,
302
+ target_platforms = target_platforms ,
303
+ )] = repo_name
304
+
305
+ if dists :
306
+ is_reproducible = False
307
+ continue
325
308
309
+ # Fallback to a pip-installed wheel
326
310
args = dict (whl_library_args ) # make a copy
327
311
args ["requirement" ] = requirement .srcs .requirement_line
328
312
if requirement .extra_pip_args :
@@ -343,13 +327,14 @@ def _create_whl_repos(
343
327
target_platforms = target_platforms or None ,
344
328
)] = repo_name
345
329
346
- if is_exposed :
347
- exposed_packages [whl_name ] = None
348
-
349
330
return struct (
350
331
is_reproducible = is_reproducible ,
351
332
whl_map = whl_map ,
352
- exposed_packages = exposed_packages ,
333
+ exposed_packages = {
334
+ whl_name : None
335
+ for whl_name , requirements in requirements_by_platform .items ()
336
+ if len ([r for r in requirements if r .is_exposed ]) > 0
337
+ },
353
338
extra_aliases = extra_aliases ,
354
339
whl_libraries = whl_libraries ,
355
340
)
0 commit comments