8000 Merge pull request #5849 from khyox/master · matplotlib/matplotlib@b07229c · GitHub
[go: up one dir, main page]

Skip to content

Commit b07229c

Browse files
committed
Merge pull request #5849 from khyox/master
Update setupext.py to solve issue #5846
1 parent c323299 commit b07229c

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

setupext.py

Lines changed: 21 additions & 13 deletions
< 8000 /tr>
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
import versioneer
1717

1818

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

2122

2223
try:
@@ -46,13 +47,13 @@ def check_output(*popenargs, **kwargs):
4647

4748

4849
if sys.platform != 'win32':
49-
if sys.version_info[0] < 3:
50+
if not PY3min:
5051
from commands import getstatusoutput
5152
else:
5253
from subprocess import getstatusoutput
5354

5455

55-
if PY3:
56+
if PY3min:
5657
import configparser
5758
else:
5859
import ConfigParser as configparser
@@ -69,7 +70,10 @@ def check_output(*popenargs, **kwargs):
6970

7071
setup_cfg = os.environ.get('MPLSETUPCFG', 'setup.cfg')
7172
if os.path.exists(setup_cfg):
72-
config = configparser.SafeConfigParser()
73+
if PY32min:
74+
config = configparser.ConfigParser()
75+
else:
76+
config = configparser.SafeConfigParser()
7377
config.read(setup_cfg)
7478

7579
try:
@@ -481,13 +485,17 @@ class OptionalPackage(SetupPackage):
481485
def get_config(cls):
482486
"""
483487
Look at `setup.cfg` and return one of ["auto", True, False] indicating
484-
if the package is at default state ("auto"), forced by the user (True)
485-
or opted-out (False).
488+
if the package is at default state ("auto"), forced by the user (case
489+
insensitively defined as 1, true, yes, on for True) or opted-out (case
490+
insensitively defined as 0, false, no, off for False).
486491
"""
487-
try:
488-
return config.getboolean(cls.config_category, cls.name)
489-
except:
490-
return "auto"
492+
conf = "auto"
493+
if config is not None and config.has_option(cls.config_category, cls.name):
494+
try:
495+
conf = config.getboolean(cls.config_category, cls.name)
496+
except ValueError:
497+
conf = config.get(cls.config_category, cls.name)
498+
return conf
491499

492500
def check(self):
493501
"""
@@ -1296,7 +1304,7 @@ def __init__(self):
12961304

12971305
def check_requirements(self):
12981306
try:
1299-
if PY3:
1307+
if PY3min:
13001308
import tkinter as Tkinter
13011309
else:
13021310
import Tkinter
@@ -1347,7 +1355,7 @@ def query_tcltk(self):
13471355
return self.tcl_tk_cache
13481356

13491357
# By this point, we already know that Tkinter imports correctly
1350-
if PY3:
1358+
if PY3min:
13511359
import tkinter as Tkinter
13521360
else:
13531361
import Tkinter
@@ -1388,7 +1396,7 @@ def query_tcltk(self):
13881396

13891397
def parse_tcl_config(self, tcl_lib_dir, tk_lib_dir):
13901398
try:
1391-
if PY3:
1399+
if PY3min:
13921400
import tkinter as Tkinter
13931401
else:
13941402
import Tkinter

0 commit comments

Comments
 (0)
0