Skip to content

Commit fc759ee

Browse files
committed
move general check() method of optional backend to base class
also split up the if/else in 3 branches to show a separate message if an configuration file backend opt-out was overridden by a forced backend install
1 parent 162cf12 commit fc759ee

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

setupext.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,21 @@ def get_config(self):
467467
self.optional = False
468468
return self.install
469469

470+
def check(self):
471+
"""
472+
This method should be called using super() even when overriding this
473+
method in a base class to check for a opt-out in the config file.
474+
"""
475+
if self.get_config() is True:
476+
return "installing"
477+
else:
478+
# Some backend extensions (e.g. Agg) need to be built for certain
479+
# other GUI backends (e.g. TkAgg) even when manually disabled
480+
if self.force is True:
481+
return "installation is forced (overriding configuration)"
482+
else:
483+
raise CheckFailed("skipping due to configuration")
484+
470485

471486
class Platform(SetupPackage):
472487
name = "platform"
@@ -981,15 +996,6 @@ def get_install_requires(self):
981996
class BackendAgg(OptionalBackendPackage):
982997
name = "agg"
983998

984-
def check(self):
985-
# The Agg backend extension needs to be built even
986-
# for certain GUI backends, such as TkAgg
987-
config = self.get_config()
988-
if config is False and self.force is False:
989-
raise CheckFailed("skipping due to configuration")
990-
else:
991-
return "installing"
992-
993999
def get_extension(self):
9941000
sources = [
9951001
"src/mplutils.cpp",

0 commit comments

Comments
 (0)