@@ -266,6 +266,10 @@ def _create_whl_repos(
266
266
logger = logger ,
267
267
)
268
268
269
+ use_downloader = {
270
+ normalize_name (s ): False
271
+ for s in pip_attr .simpleapi_skip
272
+ }
269
273
exposed_packages = {}
270
274
for whl in requirements_by_platform :
271
275
if whl .is_exposed :
@@ -313,17 +317,26 @@ def _create_whl_repos(
313
317
if v != default
314
318
})
315
319
316
- for src in whl .srcs :
320
+ for src in sorted ( whl .srcs , key = lambda x : x . filename ) :
317
321
repo = _whl_repo (
318
322
src = src ,
319
323
whl_library_args = whl_library_args ,
320
324
download_only = pip_attr .download_only ,
321
325
netrc = pip_attr .netrc ,
326
+ # NOTE @aignas 2025-07-07: we guard against an edge-case where there
327
+ # are more platforms defined than there are wheels for and users
328
+ # disallow building from sdist.
329
+ use_downloader = use_downloader .get (
330
+ whl .name ,
331
+ get_index_urls != None , # defaults to True if the get_index_urls is defined
332
+ ),
322
333
auth_patterns = pip_attr .auth_patterns ,
323
334
python_version = major_minor ,
324
335
is_multiple_versions = whl .is_multiple_versions ,
325
336
enable_pipstar = config .enable_pipstar ,
326
337
)
338
+ if repo == None :
339
+ continue
327
340
328
341
repo_name = "{}_{}" .format (pip_name , repo .repo_name )
329
342
if repo_name in whl_libraries :
@@ -342,7 +355,17 @@ def _create_whl_repos(
342
355
whl_libraries = whl_libraries ,
343
356
)
344
357
345
- def _whl_repo (* , src , whl_library_args , is_multiple_versions , download_only , netrc , auth_patterns , python_version , enable_pipstar = False ):
358
+ def _whl_repo (
359
+ * ,
360
+ src ,
361
+ whl_library_args ,
362
+ is_multiple_versions ,
363
+ download_only ,
364
+ netrc ,
365
+ auth_patterns ,
366
+ python_version ,
367
+ use_downloader ,
368
+ enable_pipstar = False ):
346
369
args = dict (whl_library_args )
347
370
args ["requirement" ] = src .requirement_line
348
371
is_whl = src .filename .endswith (".whl" )
@@ -355,19 +378,24 @@ def _whl_repo(*, src, whl_library_args, is_multiple_versions, download_only, net
355
378
args ["extra_pip_args" ] = src .extra_pip_args
356
379
357
380
if not src .url or (not is_whl and download_only ):
358
- # Fallback to a pip-installed wheel
359
- target_platforms = src .target_platforms if is_multiple_versions else []
360
- return struct (
361
- repo_name = pypi_repo_name (
362
- normalize_name (src .distribution ),
363
- * target_platforms
364
- ),
365
- args = args ,
366
- config_setting = whl_config_setting (
367
- version = python_version ,
368
- target_platforms = target_platforms or None ,
369
- ),
370
- )
381
+ if download_only and use_downloader :
382
+ # If the user did not allow using sdists and we are using the downloader
383
+ # and we are not using simpleapi_skip for this
384
+ return None
385
+ else :
386
+ # Fallback to a pip-installed wheel
387
+ target_platforms = src .target_platforms if is_multiple_versions else []
388
+ return struct (
389
+ repo_name = pypi_repo_name (
390
+ normalize_name (src .distribution ),
391
+ * target_platforms
392
+ ),
393
+ args = args ,
394
+ config_setting = whl_config_setting (
395
+ version = python_version ,
396
+ target_platforms = target_platforms or None ,
397
+ ),
398
+ )
371
399
372
400
# This is no-op because pip is not used to download the wheel.
373
401
args .pop ("download_only" , None )
0 commit comments