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

Skip to content

Commit 3c99de4

Browse files
committed
Add proper search for libpng and freetype on win32 during install.
Allow for getstatusoutput on win32 and use INCLUDE and LIB env vars Back off on the use of the environmental variables Pinpointed necessary location for INCLUDE Fix link to matplotlib-winbuild Normalize handling of library location finding Include more paths in the search Restore _check for_pkg_config behavior Implement getstatusoutput on win32 Remove win32 getstatusoutput in favor of explicit check_include_file
1 parent db5fbff commit 3c99de4

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
@@ -927,7 +934,8 @@ class FreeType(SetupPackage):
927934

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

932940
status, output = getstatusoutput("freetype-config --ftversion")
933941
if status == 0:
@@ -1004,7 +1012,8 @@ class Png(SetupPackage):
10041012

10051013
def check(self):
10061014
if sys.platform == 'win32':
1007-
return "Unknown version"
1015+
check_include_file(get_include_dirs(), 'png.h', 'png')
1016+
return 'Using unknown version found on system.'
10081017

10091018
status, output = getstatusoutput("libpng-config --version")
10101019
if status == 0:
@@ -1017,9 +1026,7 @@ def check(self):
10171026
'libpng', 'png.h',
10181027
min_version='1.2', version=version)
10191028
except CheckFailed as e:
1020-
include_dirs = [
1021-
os.path.join(dir, 'include') for dir in get_base_dirs()]
1022-
if has_include_file(include_dirs, 'png.h'):
1029+
if has_include_file(get_include_dirs(), 'png.h'):
10231030
return str(e) + ' Using unknown version found on system.'
10241031
raise
10251032

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

0 commit comments

Comments
 (0)