Merge pull request #442 from ohanar/path_fixes

Include and library path fixes
This commit is contained in:
Alex Clark ☺ 2013-12-28 06:09:51 -08:00
commit 289198b220

View File

@ -37,7 +37,10 @@ _LIB_IMAGING = (
def _add_directory(path, dir, where=None):
if dir and os.path.isdir(dir) and dir not in path:
if dir is None:
return
dir = os.path.realpath(dir)
if os.path.isdir(dir) and dir not in path:
if where is None:
path.append(dir)
else:
@ -156,6 +159,30 @@ class pil_build_ext(build_ext):
_add_directory(library_dirs, lib_root)
_add_directory(include_dirs, include_root)
# respect CFLAGS/LDFLAGS
for k in ('CFLAGS', 'LDFLAGS'):
if k in os.environ:
for match in re.finditer(r'-I([^\s]+)', os.environ[k]):
_add_directory(include_dirs, match.group(1))
for match in re.finditer(r'-L([^\s]+)', os.environ[k]):
_add_directory(library_dirs, match.group(1))
# include, rpath, if set as environment variables:
for k in ('C_INCLUDE_PATH', 'CPATH', 'INCLUDE'):
if k in os.environ:
for d in os.environ[k].split(os.path.pathsep):
_add_directory(include_dirs, d)
for k in ('LD_RUN_PATH', 'LIBRARY_PATH', 'LIB'):
if k in os.environ:
for d in os.environ[k].split(os.path.pathsep):
_add_directory(library_dirs, d)
prefix = sysconfig.get_config_var("prefix")
if prefix:
_add_directory(library_dirs, os.path.join(prefix, "lib"))
_add_directory(include_dirs, os.path.join(prefix, "include"))
#
# add platform directories
@ -187,7 +214,7 @@ class pil_build_ext(build_ext):
_add_directory(include_dirs, os.path.join(prefix, 'include'))
except:
pass # homebrew not installed
elif sys.platform.startswith("linux"):
for platform_ in (plat.processor(), plat.architecture()[0]):
@ -215,33 +242,8 @@ class pil_build_ext(build_ext):
_add_directory(library_dirs, "/usr/pkg/lib")
_add_directory(include_dirs, "/usr/pkg/include")
_add_directory(library_dirs, "/usr/local/lib")
# FIXME: check /opt/stuff directories here?
# respect CFLAGS/LDFLAGS
for k in ('CFLAGS', 'LDFLAGS'):
if k in os.environ:
for match in re.finditer(r'-I([^\s]+)', os.environ[k]):
_add_directory(include_dirs, match.group(1))
for match in re.finditer(r'-L([^\s]+)', os.environ[k]):
_add_directory(library_dirs, match.group(1))
# include, rpath, if set as environment variables:
for k in ('C_INCLUDE_PATH', 'INCLUDE'):
if k in os.environ:
for d in os.environ[k].split(os.path.pathsep):
_add_directory(include_dirs, d)
for k in ('LD_RUN_PATH', 'LIBRARY_PATH', 'LIB'):
if k in os.environ:
for d in os.environ[k].split(os.path.pathsep):
_add_directory(library_dirs, d)
prefix = sysconfig.get_config_var("prefix")
if prefix:
_add_directory(library_dirs, os.path.join(prefix, "lib"))
_add_directory(include_dirs, os.path.join(prefix, "include"))
#
# locate tkinter libraries