Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f5de590

Browse files
committed
Remove win32 getstatusoutput in favor of explicit check_include_file
1 parent bf8107f commit f5de590

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

setupext.py

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,6 @@ def check_output(*popenargs, **kwargs):
4848
from commands import getstatusoutput
4949
else:
5050
from subprocess import getstatusoutput
51-
else:
52-
def getstatusoutput(cmd):
53-
"""Return (status, output) of executing cmd in a shell."""
54-
import subprocess as sp
55-
try:
56-
proc = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
57-
except OSError:
58-
return 1, ''
59-
stdout, stderr = proc.communicate()
60-
sts = proc.returncode
61-
text = '\n'.join(stdout, stderr)
62-
if sts is None:
63-
sts = 0
64-
if text[-1:] == '\n':
65-
text = text[:-1]
66-
return sts, text
6751

6852

6953
if PY3:
@@ -136,10 +120,8 @@ def has_include_file(include_dirs, filename):
136120
Returns `True` if `filename` can be found in one of the
137121
directories in `include_dirs`.
138122
"""
139-
for var in ['INCLUDE', 'CPATH', 'C_INCLUDE_PATH',
140-
'CPLUS_INCLUDE_PATH']:
141-
env_include = os.getenv(var, '')
142-
include_dirs += env_include.replace(':', ';').split(';')
123+
if sys.platform == 'win32':
124+
include_dirs += os.environ.get('INCLUDE', '.').split(';')
143125
for dir in include_dirs:
144126
if os.path.exists(os.path.join(dir, filename)):
145127
return True
@@ -174,6 +156,13 @@ def get_base_dirs():
174156
return basedir_map.get(sys.platform, ['/usr/local', '/usr'])
175157

176158

159+
def get_include_dirs():
160+
"""
161+
Returns a list of standard include directories on this platform.
162+
"""
163+
return [os.path.join(d, 'include') for d in get_base_dirs()]
164+
165+
177166
def is_min_version(found, minversion):
178167
"""
179168
Returns `True` if `found` is at least as high a version as
@@ -945,7 +934,8 @@ class FreeType(SetupPackage):
945934

946935
def check(self):
947936
if sys.platform == 'win32':
948-
return "Unknown version"
937+
check_include_file(get_include_dirs(), 'ft2build.h', 'freetype')
938+
return 'Using unknown version found on system.'
949939

950940
status, output = getstatusoutput("freetype-config --ftversion")
951941
if status == 0:
@@ -1021,6 +1011,10 @@ class Png(SetupPackage):
10211011
name = "png"
10221012

10231013
def check(self):
1014+
if sys.platform == 'win32':
1015+
check_include_file(get_include_dirs(), 'png.h', 'png')
1016+
return 'Using unknown version found on system.'
1017+
10241018
status, output = getstatusoutput("libpng-config --version")
10251019
if status == 0:
10261020
version = output
@@ -1032,9 +1026,7 @@ def check(self):
10321026
'libpng', 'png.h',
10331027
min_version='1.2', version=version)
10341028
except CheckFailed as e:
1035-
include_dirs = [
1036-
os.path.join(dir, 'include') for dir in get_base_dirs()]
1037-
if has_include_file(include_dirs, 'png.h'):
1029+
if has_include_file(get_include_dirs(), 'png.h'):
10381030
return str(e) + ' Using unknown version found on system.'
10391031
raise
10401032

@@ -1065,7 +1057,7 @@ def check(self):
10651057
# present on this system, so check if the header files can be
10661058
# found.
10671059
include_dirs = [
1068-
os.path.join(x, 'include', 'qhull') for x in get_base_dirs()]
1060+
os.path.join(x, 'qhull') for x in get_include_dirs()]
10691061
if has_include_file(include_dirs, 'qhull_a.h'):
10701062
return 'Using system Qhull (version unknown, no pkg-config info)'
10711063
else:

0 commit comments

Comments
 (0)