Skip to content

Commit 02fc2ba

Browse files
committed
Remove Python 2 fallbacks in setup code.
1 parent 485f08b commit 02fc2ba

File tree

2 files changed

+12
-43
lines changed

2 files changed

+12
-43
lines changed

setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@
119119
'Intended Audience :: Science/Research',
120120
'License :: OSI Approved :: Python Software Foundation License',
121121
'Programming Language :: Python',
122-
'Programming Language :: Python :: 2.7',
123122
'Programming Language :: Python :: 3',
124-
'Programming Language :: Python :: 3.4',
125123
'Programming Language :: Python :: 3.5',
126124
'Programming Language :: Python :: 3.6',
127125
'Topic :: Scientific/Engineering :: Visualization',

setupext.py

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
import versioneer
2121

2222

23-
PY3min = (sys.version_info[0] >= 3)
24-
25-
2623
def _get_xdg_cache_dir():
2724
"""
2825
Return the XDG cache directory.
@@ -57,16 +54,10 @@ def _get_xdg_cache_dir():
5754
LOCAL_FREETYPE_HASH = _freetype_hashes.get(LOCAL_FREETYPE_VERSION, 'unknown')
5855

5956
if sys.platform != 'win32':
60-
if not PY3min:
61-
from commands import getstatusoutput
62-
else:
63-
from subprocess import getstatusoutput
57+
from subprocess import getstatusoutput
6458

6559

66-
if PY3min:
67-
import configparser
68-
else:
69-
import ConfigParser as configparser
60+
import configparser
7061

7162

7263
# matplotlib build options, which can be altered using setup.cfg
@@ -80,10 +71,7 @@ def _get_xdg_cache_dir():
8071

8172
setup_cfg = os.environ.get('MPLSETUPCFG', 'setup.cfg')
8273
if os.path.exists(setup_cfg):
83-
if PY3min:
84-
config = configparser.ConfigParser()
85-
else:
86-
config = configparser.SafeConfigParser()
74+
config = configparser.ConfigParser()
8775
config.read(setup_cfg)
8876

8977
if config.has_option('status', 'suppress'):
@@ -809,14 +797,7 @@ def check(self):
809797
except ImportError:
810798
msgs += [bad_pytest]
811799

812-
if PY3min:
813-
msgs += ['using unittest.mock']
814-
else:
815-
try:
816-
import mock
817-
msgs += ['using mock %s' % mock.__version__]
818-
except ImportError:
819-
msgs += [msg_template.format(package='mock')]
800+
msgs += ['using unittest.mock']
820801

821802
return ' / '.join(msgs)
822803

@@ -934,19 +915,12 @@ class Numpy(SetupPackage):
934915

935916
@staticmethod
936917
def include_dirs_hook():
937-
if PY3min:
938-
import builtins
939-
if hasattr(builtins, '__NUMPY_SETUP__'):
940-
del builtins.__NUMPY_SETUP__
941-
import imp
942-
import numpy
943-
imp.reload(numpy)
944-
else:
945-
import __builtin__
946-
if hasattr(__builtin__, '__NUMPY_SETUP__'):
947-
del __builtin__.__NUMPY_SETUP__
948-
import numpy
949-
reload(numpy)
918+
import builtins
919+
if hasattr(builtins, '__NUMPY_SETUP__'):
920+
del builtins.__NUMPY_SETUP__
921+
import imp
922+
import numpy
923+
imp.reload(numpy)
950924

951925
ext = Extension('test', [])
952926
ext.include_dirs.append(numpy.get_include())
@@ -1157,10 +1131,7 @@ def do_custom_build(self):
11571131
pass
11581132

11591133
if not os.path.isfile(tarball_path):
1160-
if PY3min:
1161-
from urllib.request import urlretrieve
1162-
else:
1163-
from urllib import urlretrieve
1134+
from urllib.request import urlretrieve
11641135

11651136
if not os.path.exists('build'):
11661137
os.makedirs('build')
@@ -1473,7 +1444,7 @@ def check(self):
14731444
def runtime_check(self):
14741445
""" Checks whether TkAgg runtime dependencies are met
14751446
"""
1476-
pkg_name = 'tkinter' if PY3min else 'Tkinter'
1447+
pkg_name = 'tkinter'
14771448
try:
14781449
import_module(pkg_name)
14791450
except ImportError:

0 commit comments

Comments
 (0)