@@ -48,22 +48,6 @@ def check_output(*popenargs, **kwargs):
48
48
from commands import getstatusoutput
49
49
else :
50
50
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
67
51
68
52
69
53
if PY3 :
@@ -136,10 +120,8 @@ def has_include_file(include_dirs, filename):
136
120
Returns `True` if `filename` can be found in one of the
137
121
directories in `include_dirs`.
138
122
"""
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 (';' )
143
125
for dir in include_dirs :
144
126
if os .path .exists (os .path .join (dir , filename )):
145
127
return True
@@ -174,6 +156,13 @@ def get_base_dirs():
174
156
return basedir_map .get (sys .platform , ['/usr/local' , '/usr' ])
175
157
176
158
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
+
177
166
def is_min_version (found , minversion ):
178
167
"""
179
168
Returns `True` if `found` is at least as high a version as
@@ -945,7 +934,8 @@ class FreeType(SetupPackage):
945
934
946
935
def check (self ):
947
936
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.'
949
939
950
940
status , output = getstatusoutput ("freetype-config --ftversion" )
951
941
if status == 0 :
@@ -1021,6 +1011,10 @@ class Png(SetupPackage):
1021
1011
name = "png"
1022
1012
1023
1013
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
+
1024
1018
status , output = getstatusoutput ("libpng-config --version" )
1025
1019
if status == 0 :
1026
1020
version = output
@@ -1032,9 +1026,7 @@ def check(self):
1032
1026
'libpng' , 'png.h' ,
1033
1027
min_version = '1.2' , version = version )
1034
1028
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' ):
1038
1030
return str (e ) + ' Using unknown version found on system.'
1039
1031
raise
1040
1032
@@ -1065,7 +1057,7 @@ def check(self):
1065
1057
# present on this system, so check if the header files can be
1066
1058
# found.
1067
1059
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 ()]
1069
1061
if has_include_file (include_dirs , 'qhull_a.h' ):
1070
1062
return 'Using system Qhull (version unknown, no pkg-config info)'
1071
1063
else :
0 commit comments