9
9
import textwrap
10
10
import traceback
11
11
import typing
12
- from collections .abc import Iterable , Sequence
12
+ from collections .abc import Generator , Iterable , Sequence
13
13
from pathlib import Path
14
14
from tempfile import mkdtemp
15
15
from typing import Any , Literal , TextIO
@@ -369,41 +369,61 @@ def print_preamble(platform: str, options: Options, identifiers: Sequence[str])
369
369
print (f"Cache folder: { CIBW_CACHE_PATH } " )
370
370
print ()
371
371
372
- warnings = detect_warnings (options = options , identifiers = identifiers )
372
+ warnings = detect_warnings (options = options )
373
373
for warning in warnings :
374
374
log .warning (warning )
375
375
376
- print ("Here we go!\n " )
376
+ error_list = list (detect_errors (options = options , identifiers = identifiers ))
377
+ if error_list :
378
+ for error in error_list :
379
+ log .error (error )
380
+ msg = "\n " .join (error_list )
381
+ raise errors .ConfigurationError (msg )
377
382
383
+ print ("Here we go!\n " )
378
384
379
- def detect_warnings (* , options : Options , identifiers : Iterable [str ]) -> list [str ]:
380
- warnings = []
381
385
382
- python_version_deprecation = (( 3 , 11 ), 3 )
383
- if sys . version_info [: 2 ] < python_version_deprecation [ 0 ]:
384
- python_version = "." . join ( map ( str , python_version_deprecation [ 0 ]))
385
- msg = (
386
- f"cibuildwheel { python_version_deprecation [ 1 ] } will require Python { python_version } +, "
387
- "please upgrade the Python version used to run cibuildwheel. "
388
- "This does not affect the versions you can target when building wheels. See: https://cibuildwheel.pypa.io/en/stable/#what-does-it-do "
386
+ def detect_errors ( * , options : Options , identifiers : Iterable [ str ]) -> Generator [ str , None , None ]:
387
+ # Check for deprecated CIBW_FREE_THREADED_SUPPORT environment variable
388
+ if "CIBW_FREE_THREADED_SUPPORT" in os . environ :
389
+ yield (
390
+ "CIBW_FREE_THREADED_SUPPORT environment variable is no longer supported. "
391
+ 'Use tool.cibuildwheel.enable = ["cpython-freethreading"] in pyproject.toml '
392
+ "or set CIBW_ENABLE=cpython-freethreading instead. "
389
393
)
390
- warnings .append (msg )
391
394
392
- # warn about deprecated {python} and {pip}
395
+ # Deprecated {python} and {pip}
393
396
for option_name in ["test_command" , "before_build" ]:
394
397
option_values = [getattr (options .build_options (i ), option_name ) for i in identifiers ]
395
398
396
399
if any (o and ("{python}" in o or "{pip}" in o ) for o in option_values ):
397
400
# Reminder: in an f-string, double braces means literal single brace
398
- msg = (
401
+ yield (
399
402
f"{ option_name } : '{{python}}' and '{{pip}}' are no longer supported "
400
403
"and have been removed in cibuildwheel 3. Simply use 'python' or 'pip' instead."
401
404
)
402
- raise errors .ConfigurationError (msg )
405
+
406
+
407
+ def detect_warnings (* , options : Options ) -> Generator [str , None , None ]:
408
+ python_version_deprecation = ((3 , 11 ), 3 )
409
+ if sys .version_info [:2 ] < python_version_deprecation [0 ]:
410
+ python_version = "." .join (map (str , python_version_deprecation [0 ]))
411
+ yield (
412
+ f"cibuildwheel { python_version_deprecation [1 ]} will require Python { python_version } +, "
413
+ "please upgrade the Python version used to run cibuildwheel. "
414
+ "This does not affect the versions you can target when building wheels. See: https://cibuildwheel.pypa.io/en/stable/#what-does-it-do"
415
+ )
403
416
404
417
build_selector = options .globals .build_selector
405
418
test_selector = options .globals .test_selector
406
419
420
+ if EnableGroup .CPythonExperimentalRiscV64 in build_selector .enable :
421
+ yield (
422
+ "'cpython-experimental-riscv64' enable is deprecated and will be removed in a future version. "
423
+ "It should be removed from tool.cibuildwheel.enable in pyproject.toml "
424
+ "or CIBW_ENABLE environment variable."
425
+ )
426
+
407
427
all_valid_identifiers = [
408
428
config .identifier
409
429
for module in ALL_PLATFORM_MODULES .values ()
@@ -417,27 +437,25 @@ def detect_warnings(*, options: Options, identifiers: Iterable[str]) -> list[str
417
437
identifier for identifier in all_valid_identifiers if enabled_selector (identifier )
418
438
]
419
439
420
- warnings += check_for_invalid_selectors (
440
+ yield from check_for_invalid_selectors (
421
441
selector_name = "build" ,
422
442
selector_value = build_selector .build_config ,
423
443
all_valid_identifiers = all_valid_identifiers ,
424
444
all_enabled_identifiers = all_enabled_identifiers ,
425
445
)
426
- warnings += check_for_invalid_selectors (
446
+ yield from check_for_invalid_selectors (
427
447
selector_name = "skip" ,
428
448
selector_value = build_selector .skip_config ,
429
449
all_valid_identifiers = all_valid_identifiers ,
430
450
all_enabled_identifiers = all_enabled_identifiers ,
431
451
)
432
- warnings += check_for_invalid_selectors (
452
+ yield from check_for_invalid_selectors (
433
453
selector_name = "test_skip" ,
434
454
selector_value = test_selector .skip_config ,
435
455
all_valid_identifiers = all_valid_identifiers ,
436
456
all_enabled_identifiers = all_enabled_identifiers ,
437
457
)
438
458
439
- return warnings
440
-
441
459
442
460
def check_for_invalid_selectors (
443
461
* ,
@@ -449,17 +467,31 @@ def check_for_invalid_selectors(
449
467
warnings = []
450
468
451
469
for selector in selector_value .split ():
452
- if not any (selector_matches (selector , i ) for i in all_enabled_identifiers ):
470
+ selector_ = selector
471
+ if selector_name == "test_skip" :
472
+ # macosx_universal2 uses an additional identifier for tests which ends with ":{arch}"
473
+ values = selector .split (":" )
474
+ universal2_identifiers = filter (
475
+ lambda x : x .endswith ("-macosx_universal2" ), all_valid_identifiers
476
+ )
477
+ if len (values ) == 2 and any (
478
+ selector_matches (selector_ , f"{ i } :{ arch } " )
479
+ for i in universal2_identifiers
480
+ for arch in ["arm64" , "x86_64" ]
481
+ ):
482
+ # just ignore the arch part in the rest of the check
483
+ selector_ = values [0 ]
484
+ if not any (selector_matches (selector_ , i ) for i in all_enabled_identifiers ):
453
485
msg = f"Invalid { selector_name } selector: { selector !r} . "
454
486
error_type : type = errors .ConfigurationError
455
487
456
- if any (selector_matches (selector , i ) for i in all_valid_identifiers ):
488
+ if any (selector_matches (selector_ , i ) for i in all_valid_identifiers ):
457
489
msg += "This selector matches a group that wasn't enabled. Enable it using the `enable` option or remove this selector. "
458
490
459
- if "p2" in selector or "p35" in selector :
491
+ if "p2" in selector_ or "p35" in selector_ :
460
492
msg += f"cibuildwheel 3.x no longer supports Python < 3.8. Please use the 1.x series or update `{ selector_name } `. "
461
493
error_type = errors .DeprecationError
462
- if "p36" in selector or "p37" in selector :
494
+ if "p36" in selector_ or "p37" in selector_ :
463
495
msg += f"cibuildwheel 3.x no longer supports Python < 3.8. Please use the 2.x series or update `{ selector_name } `. "
464
496
error_type = errors .DeprecationError
465
497
0 commit comments