17
17
import versioneer
18
18
19
19
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 )
21
22
22
23
23
24
# This is the version of FreeType to use when building a local
28
29
LOCAL_FREETYPE_HASH = '348e667d728c597360e4a87c16556597'
29
30
30
31
if sys .platform != 'win32' :
31
- if sys . version_info [ 0 ] < 3 :
32
+ if not PY3min :
32
33
from commands import getstatusoutput
33
34
else :
34
35
from subprocess import getstatusoutput
35
36
36
37
37
- if PY3 :
38
+ if PY3min :
38
39
import configparser
39
40
else :
40
41
import ConfigParser as configparser
51
52
52
53
setup_cfg = os .environ .get ('MPLSETUPCFG' , 'setup.cfg' )
53
54
if os .path .exists (setup_cfg ):
54
- config = configparser .SafeConfigParser ()
55
+ if PY32min :
56
+ config = configparser .ConfigParser ()
57
+ else :
58
+ config = configparser .SafeConfigParser ()
55
59
config .read (setup_cfg )
56
60
57
61
if config .has_option ('status' , 'suppress' ):
@@ -495,12 +499,17 @@ class OptionalPackage(SetupPackage):
495
499
def get_config (cls ):
496
500
"""
497
501
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).
500
505
"""
506
+ conf = "auto"
501
507
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
504
513
505
514
def check (self ):
506
515
"""
@@ -1393,7 +1402,7 @@ def __init__(self):
1393
1402
1394
1403
def check_requirements (self ):
1395
1404
try :
1396
- if PY3 :
1405
+ if PY3min :
1397
1406
import tkinter as Tkinter
1398
1407
else :
1399
1408
import Tkinter
@@ -1444,7 +1453,7 @@ def query_tcltk(self):
1444
1453
return self .tcl_tk_cache
1445
1454
1446
1455
# By this point, we already know that Tkinter imports correctly
1447
- if PY3 :
1456
+ if PY3min :
1448
1457
import tkinter as Tkinter
1449
1458
else :
1450
1459
import Tkinter
@@ -1485,7 +1494,7 @@ def query_tcltk(self):
1485
1494
1486
1495
def parse_tcl_config (self , tcl_lib_dir , tk_lib_dir ):
1487
1496
try :
1488
- if PY3 :
1497
+ if PY3min :
1489
1498
import tkinter as Tkinter
1490
1499
else :
1491
1500
import Tkinter
0 commit comments