Skip to content

Commit d10e26e

Browse files
committed
Merge pull request #3510 from blink1073/fix-setupext
BLD : improve setupext.py on windows
1 parent 75fbc9e commit d10e26e

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

setupext.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ def has_include_file(include_dirs, filename):
120120
Returns `True` if `filename` can be found in one of the
121121
directories in `include_dirs`.
122122
"""
123+
if sys.platform == 'win32':
124+
include_dirs += os.environ.get('INCLUDE', '.').split(';')
123125
for dir in include_dirs:
124126
if os.path.exists(os.path.join(dir, filename)):
125127
return True
@@ -130,8 +132,6 @@ def check_include_file(include_dirs, filename, package):
130132
"""
131133
Raises an exception if the given include file can not be found.
132134
"""
133-
if sys.platform == 'win32':
134-
include_dirs.extend(os.getenv('INCLUDE', '.').split(';'))
135135
if not has_include_file(include_dirs, filename):
136136
raise CheckFailed(
137137
"The C/C++ header for %s (%s) could not be found. You "
@@ -156,6 +156,13 @@ def get_base_dirs():
156156
return basedir_map.get(sys.platform, ['/usr/local', '/usr'])
157157

158158

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+
159166
def is_min_version(found, minversion):
160167
"""
161168
Returns `True` if `found` is at least as high a version as
@@ -930,7 +937,8 @@ class FreeType(SetupPackage):
930937

931938
def check(self):
932939
if sys.platform == 'win32':
933-
return "Unknown version"
940+
check_include_file(get_include_dirs(), 'ft2build.h', 'freetype')
941+
return 'Using unknown version found on system.'
934942

935943
status, output = getstatusoutput("freetype-config --ftversion")
936944
if status == 0:
@@ -1007,7 +1015,8 @@ class Png(SetupPackage):
10071015

10081016
def check(self):
10091017
if sys.platform == 'win32':
1010-
return "Unknown version"
1018+
check_include_file(get_include_dirs(), 'png.h', 'png')
1019+
return 'Using unknown version found on system.'
10111020

10121021
status, output = getstatusoutput("libpng-config --version")
10131022
if status == 0:
@@ -1020,9 +1029,7 @@ def check(self):
10201029
'libpng', 'png.h',
10211030
min_version='1.2', version=version)
10221031
except CheckFailed as e:
1023-
include_dirs = [
1024-
os.path.join(dir, 'include') for dir in get_base_dirs()]
1025-
if has_include_file(include_dirs, 'png.h'):
1032+
if has_include_file(get_include_dirs(), 'png.h'):
10261033
return str(e) + ' Using unknown version found on system.'
10271034
raise
10281035

@@ -1053,7 +1060,7 @@ def check(self):
10531060
# present on this system, so check if the header files can be
10541061
# found.
10551062
include_dirs = [
1056-
os.path.join(x, 'include', 'qhull') for x in get_base_dirs()]
1063+
os.path.join(x, 'qhull') for x in get_include_dirs()]
10571064
if has_include_file(include_dirs, 'qhull_a.h'):
10581065
return 'Using system Qhull (version unknown, no pkg-config info)'
10591066
else:

0 commit comments

Comments
 (0)