|
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'): |
@@ -483,12 +487,17 @@ class OptionalPackage(SetupPackage): |
483 | 487 | def get_config(cls): |
484 | 488 | """ |
485 | 489 | Look at `setup.cfg` and return one of ["auto", True, False] indicating |
486 | | - if the package is at default state ("auto"), forced by the user (True) |
487 | | - or opted-out (False). |
| 490 | + if the package is at default state ("auto"), forced by the user (case |
| 491 | + insensitively defined as 1, true, yes, on for True) or opted-out (case |
| 492 | + insensitively defined as 0, false, no, off for False). |
488 | 493 | """ |
| 494 | + conf = "auto" |
489 | 495 | if config is not None and config.has_option(cls.config_category, cls.name): |
490 | | - return config.get(cls.config_category, cls.name) |
491 | | - return "auto" |
| 496 | + try: |
| 497 | + conf = config.getboolean(cls.config_category, cls.name) |
| 498 | + except ValueError: |
| 499 | + conf = config.get(cls.config_category, cls.name) |
| 500 | + return conf |
492 | 501 |
|
493 | 502 | def check(self): |
494 | 503 | """ |
@@ -1376,7 +1385,7 @@ def __init__(self): |
1376 | 1385 |
|
1377 | 1386 | def check_requirements(self): |
1378 | 1387 | try: |
1379 | | - if PY3: |
| 1388 | + if PY3min: |
1380 | 1389 | import tkinter as Tkinter |
1381 | 1390 | else: |
1382 | 1391 | import Tkinter |
@@ -1427,7 +1436,7 @@ def query_tcltk(self): |
1427 | 1436 | return self.tcl_tk_cache |
1428 | 1437 |
|
1429 | 1438 | # By this point, we already know that Tkinter imports correctly |
1430 | | - if PY3: |
| 1439 | + if PY3min: |
1431 | 1440 | import tkinter as Tkinter |
1432 | 1441 | else: |
1433 | 1442 | import Tkinter |
@@ -1468,7 +1477,7 @@ def query_tcltk(self): |
1468 | 1477 |
|
1469 | 1478 | def parse_tcl_config(self, tcl_lib_dir, tk_lib_dir): |
1470 | 1479 | try: |
1471 | | - if PY3: |
| 1480 | + if PY3min: |
1472 | 1481 | import tkinter as Tkinter |
1473 | 1482 | else: |
1474 | 1483 | import Tkinter |
|
0 commit comments