Skip to content

Commit 6eaa004

Browse files
committed
Merge pull request matplotlib#5849 from khyox/master
Update setupext.py to solve issue matplotlib#5846
2 parents eebf258 + d1d59c4 commit 6eaa004

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

setupext.py

+20-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
import versioneer
1818

1919

20-
PY3 = (sys.version_info[0] >= 3)
20+
PY3min = (sys.version_info[0] >= 3)
21+
PY32min = (PY3min and sys.version_info[1] >= 2 or sys.version_info[0] > 3)
2122

2223

2324
# This is the version of FreeType to use when building a local
@@ -28,13 +29,13 @@
2829
LOCAL_FREETYPE_HASH = '348e667d728c597360e4a87c16556597'
2930

3031
if sys.platform != 'win32':
31-
if sys.version_info[0] < 3:
32+
if not PY3min:
3233
from commands import getstatusoutput
3334
else:
3435
from subprocess import getstatusoutput
3536

3637

37-
if PY3:
38+
if PY3min:
3839
import configparser
3940
else:
4041
import ConfigParser as configparser
@@ -51,7 +52,10 @@
5152

5253
setup_cfg = os.environ.get('MPLSETUPCFG', 'setup.cfg')
5354
if os.path.exists(setup_cfg):
54-
config = configparser.SafeConfigParser()
55+
if PY32min:
56+
config = configparser.ConfigParser()
57+
else:
58+
config = configparser.SafeConfigParser()
5559
config.read(setup_cfg)
5660

5761
if config.has_option('status', 'suppress'):
@@ -495,12 +499,17 @@ class OptionalPackage(SetupPackage):
495499
def get_config(cls):
496500
"""
497501
Look at `setup.cfg` and return one of ["auto", True, False] indicating
498-
if the package is at default state ("auto"), forced by the user (True)
499-
or opted-out (False).
502+
if the package is at default state ("auto"), forced by the user (case
503+
insensitively defined as 1, true, yes, on for True) or opted-out (case
504+
insensitively defined as 0, false, no, off for False).
500505
"""
506+
conf = "auto"
501507
if config is not None and config.has_option(cls.config_category, cls.name):
502-
return config.get(cls.config_category, cls.name)
503-
return "auto"
508+
try:
509+
conf = config.getboolean(cls.config_category, cls.name)
510+
except ValueError:
511+
conf = config.get(cls.config_category, cls.name)
512+
return conf
504513

505514
def check(self):
506515
"""
@@ -1393,7 +1402,7 @@ def __init__(self):
13931402

13941403
def check_requirements(self):
13951404
try:
1396-
if PY3:
1405+
if PY3min:
13971406
import tkinter as Tkinter
13981407
else:
13991408
import Tkinter
@@ -1444,7 +1453,7 @@ def query_tcltk(self):
14441453
return self.tcl_tk_cache
14451454

14461455
# By this point, we already know that Tkinter imports correctly
1447-
if PY3:
1456+
if PY3min:
14481457
import tkinter as Tkinter
14491458
else:
14501459
import Tkinter
@@ -1485,7 +1494,7 @@ def query_tcltk(self):
14851494

14861495
def parse_tcl_config(self, tcl_lib_dir, tk_lib_dir):
14871496
try:
1488-
if PY3:
1497+
if PY3min:
14891498
import tkinter as Tkinter
14901499
else:
14911500
import Tkinter

0 commit comments

Comments
 (0)