16
16
import versioneer
17
17
18
18
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 )
20
21
21
22
22
23
try :
@@ -46,13 +47,13 @@ def check_output(*popenargs, **kwargs):
<
8000
/tr>46
47
47
48
48
49
if sys .platform != 'win32' :
49
- if sys . version_info [ 0 ] < 3 :
50
+ if not PY3min :
50
51
from commands import getstatusoutput
51
52
else :
52
53
from subprocess import getstatusoutput
53
54
54
55
55
- if PY3 :
56
+ if PY3min :
56
57
import configparser
57
58
else :
58
59
import ConfigParser as configparser
@@ -69,7 +70,10 @@ def check_output(*popenargs, **kwargs):
69
70
70
71
setup_cfg = os .environ .get ('MPLSETUPCFG' , 'setup.cfg' )
71
72
if os .path .exists (setup_cfg ):
72
- config = configparser .SafeConfigParser ()
73
+ if PY32min :
74
+ config = configparser .ConfigParser ()
75
+ else :
76
+ config = configparser .SafeConfigParser ()
73
77
config .read (setup_cfg )
74
78
75
79
try :
@@ -481,13 +485,17 @@ class OptionalPackage(SetupPackage):
481
485
def get_config (cls ):
482
486
"""
483
487
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).
486
491
"""
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
491
499
492
500
def check (self ):
493
501
"""
@@ -1296,7 +1304,7 @@ def __init__(self):
1296
1304
1297
1305
def check_requirements (self ):
1298
1306
try :
1299
- if PY3 :
1307
+ if PY3min :
1300
1308
import tkinter as Tkinter
1301
1309
else :
1302
1310
import Tkinter
@@ -1347,7 +1355,7 @@ def query_tcltk(self):
1347
1355
return self .tcl_tk_cache
1348
1356
1349
1357
# By this point, we already know that Tkinter imports correctly
1350
- if PY3 :
1358
+ if PY3min :
1351
1359
import tkinter as Tkinter
1352
1360
else :
1353
1361
import Tkinter
@@ -1388,7 +1396,7 @@ def query_tcltk(self):
1388
1396
1389
1397
def parse_tcl_config (self , tcl_lib_dir , tk_lib_dir ):
1390
1398
try :
1391
- if PY3 :
1399
+ if PY3min :
1392
1400
import tkinter as Tkinter
1393
1401
else :
1394
1402
import Tkinter
0 commit comments