1
- # NOTE: This file must remain Python 2 compatible for the forseeable future,
2
- # to ensure that we error out properly for people with outdated setuptools
3
- # and/or pip.
4
1
from __future__ import print_function , absolute_import
5
2
6
3
from importlib import import_module
14
11
import os
15
12
import platform
16
13
import re
14
+ import shutil
17
15
import subprocess
18
16
from subprocess import check_output
19
17
import sys
20
18
import warnings
21
19
from textwrap import fill
22
- import shutil
23
20
import versioneer
24
21
25
22
26
- PY3min = (sys .version_info [0 ] >= 3 )
27
-
28
-
29
23
def _get_xdg_cache_dir ():
30
24
"""
31
25
Return the XDG cache directory.
@@ -60,16 +54,10 @@ def _get_xdg_cache_dir():
60
54
LOCAL_FREETYPE_HASH = _freetype_hashes .get (LOCAL_FREETYPE_VERSION , 'unknown' )
61
55
62
56
if sys .platform != 'win32' :
63
- if not PY3min :
64
- from commands import getstatusoutput
65
- else :
66
- from subprocess import getstatusoutput
57
+ from subprocess import getstatusoutput
67
58
68
59
69
- if PY3min :
70
- import configparser
71
- else :
72
- import ConfigParser as configparser
60
+ import configparser
73
61
74
62
75
63
# matplotlib build options, which can be altered using setup.cfg
@@ -83,10 +71,7 @@ def _get_xdg_cache_dir():
83
71
84
72
setup_cfg = os .environ .get ('MPLSETUPCFG' , 'setup.cfg' )
85
73
if os .path .exists (setup_cfg ):
86
- if PY3min :
87
- config = configparser .ConfigParser ()
88
- else :
89
- config = configparser .SafeConfigParser ()
74
+ config = configparser .ConfigParser ()
90
75
config .read (setup_cfg )
91
76
92
77
if config .has_option ('status' , 'suppress' ):
@@ -567,11 +552,7 @@ def _try_managers(*managers):
567
552
for manager in managers :
568
553
pkg_name = self .pkg_names .get (manager , None )
569
554
if pkg_name :
570
- try :
571
- # `shutil.which()` can be used when Python 2.7 support
572
- # is dropped. It is available in Python 3.3+
573
- _ = check_output (["which" , manager ],
574
- stderr = subprocess .STDOUT )
555
+ if shutil .which (manager ) is not None :
575
556
if manager == 'port' :
576
557
pkgconfig = 'pkgconfig'
577
558
else :
@@ -580,8 +561,6 @@ def _try_managers(*managers):
580
561
'and pkg-config with `{1} install {3}`'
581
562
.format (self .name , manager , pkg_name ,
582
563
pkgconfig ))
583
- except subprocess .CalledProcessError :
584
- pass
585
564
586
565
message = None
587
566
if sys .platform == "win32" :
@@ -812,15 +791,6 @@ def check(self):
812
791
except ImportError :
813
792
msgs += [bad_pytest ]
814
793
815
- if PY3min :
816
- msgs += ['using unittest.mock' ]
817
- else :
818
- try :
819
- import mock
820
- msgs += ['using mock %s' % mock .__version__ ]
821
- except ImportError :
822
- msgs += [msg_template .format (package = 'mock' )]
823
-
824
794
return ' / ' .join (msgs )
825
795
826
796
def get_packages (self ):
@@ -937,19 +907,12 @@ class Numpy(SetupPackage):
937
907
938
908
@staticmethod
939
909
def include_dirs_hook ():
940
- if PY3min :
941
- import builtins
942
- if hasattr (builtins , '__NUMPY_SETUP__' ):
943
- del builtins .__NUMPY_SETUP__
944
- import imp
945
- import numpy
946
- imp .reload (numpy )
947
- else :
948
- import __builtin__
949
- if hasattr (__builtin__ , '__NUMPY_SETUP__' ):
950
- del __builtin__ .__NUMPY_SETUP__
951
- import numpy
952
- reload (numpy )
910
+ import builtins
911
+ if hasattr (builtins , '__NUMPY_SETUP__' ):
912
+ del builtins .__NUMPY_SETUP__
913
+ import imp
914
+ import numpy
915
+ imp .reload (numpy )
953
916
954
917
ext = Extension ('test' , [])
955
918
ext .include_dirs .append (numpy .get_include ())
@@ -990,10 +953,10 @@ def add_flags(self, ext):
990
953
ext .define_macros .append (('__STDC_FORMAT_MACROS' , 1 ))
991
954
992
955
def get_setup_requires (self ):
993
- return ['numpy>=1.7.1 ' ]
956
+ return ['numpy>=1.10.0 ' ]
994
957
995
958
def get_install_requires (self ):
996
- return ['numpy>=1.7.1 ' ]
959
+ return ['numpy>=1.10.0 ' ]
997
960
998
961
999
962
class LibAgg (SetupPackage ):
@@ -1146,11 +1109,7 @@ def do_custom_build(self):
1146
1109
if (tarball_cache_path is not None and
1147
1110
os .path .isfile (tarball_cache_path )):
1148
1111
if get_file_hash (tarball_cache_path ) == LOCAL_FREETYPE_HASH :
1149
- try :
1150
- os .makedirs ('build' )
1151
- except OSError :
1152
- # Don't care if it exists.
1153
- pass
1112
+ os .makedirs ('build' , exist_ok = True )
1154
1113
try :
1155
1114
shutil .copy (tarball_cache_path , tarball_path )
1156
1115
print ('Using cached tarball: {}'
@@ -1160,10 +1119,7 @@ def do_custom_build(self):
1160
1119
pass
1161
1120
1162
1121
if not os .path .isfile (tarball_path ):
1163
- if PY3min :
1164
- from urllib .request import urlretrieve
1165
- else :
1166
- from urllib import urlretrieve
1122
+ from urllib .request import urlretrieve
1167
1123
1168
1124
if not os .path .exists ('build' ):
1169
1125
os .makedirs ('build' )
@@ -1193,11 +1149,7 @@ def do_custom_build(self):
1193
1149
"You can download the file by "
1194
1150
"alternative means and copy it "
1195
1151
" to '{0}'" .format (tarball_path ))
1196
- try :
1197
- os .makedirs (tarball_cache_dir )
1198
- except OSError :
1199
- # Don't care if it exists.
1200
- pass
1152
+ os .makedirs (tarball_cache_dir , exist_ok = True )
1201
1153
try :
1202
1154
shutil .copy (tarball_path , tarball_cache_path )
1203
1155
print ('Cached tarball at: {}' .format (tarball_cache_path ))
@@ -1480,7 +1432,7 @@ def check(self):
1480
1432
def runtime_check (self ):
1481
1433
""" Checks whether TkAgg runtime dependencies are met
1482
1434
"""
1483
- pkg_name = 'tkinter' if PY3min else 'Tkinter'
1435
+ pkg_name = 'tkinter'
1484
1436
try :
1485
1437
import_module (pkg_name )
1486
1438
except ImportError :
0 commit comments