From 3c99de42f70fdd1577942e02ca417d43275fb8b6 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Fri, 12 Sep 2014 23:46:46 -0500 Subject: [PATCH] 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 --- setupext.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/setupext.py b/setupext.py index 63e87d1352b0..e2024440c406 100755 --- a/setupext.py +++ b/setupext.py @@ -120,6 +120,8 @@ def has_include_file(include_dirs, filename): Returns `True` if `filename` can be found in one of the directories in `include_dirs`. """ + if sys.platform == 'win32': + include_dirs += os.environ.get('INCLUDE', '.').split(';') for dir in include_dirs: if os.path.exists(os.path.join(dir, filename)): return True @@ -130,8 +132,6 @@ def check_include_file(include_dirs, filename, package): """ Raises an exception if the given include file can not be found. """ - if sys.platform == 'win32': - include_dirs.extend(os.getenv('INCLUDE', '.').split(';')) if not has_include_file(include_dirs, filename): raise CheckFailed( "The C/C++ header for %s (%s) could not be found. You " @@ -156,6 +156,13 @@ def get_base_dirs(): return basedir_map.get(sys.platform, ['/usr/local', '/usr']) +def get_include_dirs(): + """ + Returns a list of standard include directories on this platform. + """ + return [os.path.join(d, 'include') for d in get_base_dirs()] + + def is_min_version(found, minversion): """ Returns `True` if `found` is at least as high a version as @@ -927,7 +934,8 @@ class FreeType(SetupPackage): def check(self): if sys.platform == 'win32': - return "Unknown version" + check_include_file(get_include_dirs(), 'ft2build.h', 'freetype') + return 'Using unknown version found on system.' status, output = getstatusoutput("freetype-config --ftversion") if status == 0: @@ -1004,7 +1012,8 @@ class Png(SetupPackage): def check(self): if sys.platform == 'win32': - return "Unknown version" + check_include_file(get_include_dirs(), 'png.h', 'png') + return 'Using unknown version found on system.' status, output = getstatusoutput("libpng-config --version") if status == 0: @@ -1017,9 +1026,7 @@ def check(self): 'libpng', 'png.h', min_version='1.2', version=version) except CheckFailed as e: - include_dirs = [ - os.path.join(dir, 'include') for dir in get_base_dirs()] - if has_include_file(include_dirs, 'png.h'): + if has_include_file(get_include_dirs(), 'png.h'): return str(e) + ' Using unknown version found on system.' raise @@ -1050,7 +1057,7 @@ def check(self): # present on this system, so check if the header files can be # found. include_dirs = [ - os.path.join(x, 'include', 'qhull') for x in get_base_dirs()] + os.path.join(x, 'qhull') for x in get_include_dirs()] if has_include_file(include_dirs, 'qhull_a.h'): return 'Using system Qhull (version unknown, no pkg-config info)' else: