Skip to content

Commit

Permalink
Add proper search for libpng and freetype on win32 during install.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
blink1073 committed Sep 14, 2014
1 parent db5fbff commit 3c99de4
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions setupext.py
Expand Up @@ -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
Expand All @@ -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 "
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3c99de4

Please sign in to comment.