@@ -452,47 +452,27 @@ def get_config(cls):
452
452
453
453
def check (self ):
454
454
"""
455
- Do not override this method!
455
+ Check whether ``setup.cfg`` requests this package to be installed.
456
456
457
- For custom dependency checks override self.check_requirements().
458
- Two things are checked: Configuration file and requirements.
457
+ May be overridden by subclasses for additional checks.
459
458
"""
460
459
# Check configuration file
461
460
conf = self .get_config ()
462
461
# Default "auto" state or install forced by user
463
462
if conf in [True , 'auto' ]:
464
- message = "installing"
465
463
# Set non-optional if user sets `True` in config
466
464
if conf is True :
467
465
self .optional = False
466
+ return "installing"
468
467
# Configuration opt-out by user
469
468
else :
470
469
# Some backend extensions (e.g. Agg) need to be built for certain
471
470
# other GUI backends (e.g. TkAgg) even when manually disabled
472
471
if self .force is True :
473
- message = "installing forced (config override)"
472
+ return "installing forced (config override)"
474
473
else :
475
474
raise CheckFailed ("skipping due to configuration" )
476
475
477
- # Check requirements and add extra information (if any) to message.
478
- # If requirements are not met a CheckFailed should be raised in there.
479
- additional_info = self .check_requirements ()
480
- if additional_info :
481
- message += ", " + additional_info
482
-
483
- # No CheckFailed raised until now, return install message.
484
- return message
485
-
486
- def check_requirements (self ):
487
- """
488
- Override this method to do custom dependency checks.
489
-
490
- - Raise CheckFailed() if requirements are not met.
491
- - Return message with additional information, or an empty string
492
- (or None) for no additional information.
493
- """
494
- return ""
495
-
496
476
497
477
class OptionalBackendPackage (OptionalPackage ):
498
478
config_category = "gui_support"
@@ -979,11 +959,10 @@ def add_flags(self, ext):
979
959
class BackendMacOSX (OptionalBackendPackage ):
980
960
name = 'macosx'
981
961
982
- def check_requirements (self ):
962
+ def check (self ):
983
963
if sys .platform != 'darwin' :
984
964
raise CheckFailed ("Mac OS-X only" )
985
-
986
- return 'darwin'
965
+ return super ().check ()
987
966
988
967
def get_extension (self ):
989
968
sources = [
@@ -1008,9 +987,10 @@ class Dlls(OptionalPackageData):
1008
987
"""
1009
988
name = "dlls"
1010
989
1011
- def check_requirements (self ):
990
+ def check (self ):
1012
991
if sys .platform != 'win32' :
1013
992
raise CheckFailed ("Microsoft Windows only" )
993
+ return super ().check ()
1014
994
1015
995
def get_package_data (self ):
1016
996
return {'' : ['*.dll' ]}
0 commit comments