Skip to content

Commit

Permalink
Put /usr/local paths after the relative paths in library_dirs and
Browse files Browse the repository at this point in the history
include_dirs, so installed non-matching shared libraries don't break extension
module linking.  Fixes issue 10520.
  • Loading branch information
warsaw committed Nov 24, 2010
1 parent 1b9df39 commit 807bd0a
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@
_BUILDDIR_COOKIE = "pybuilddir.txt"

def add_dir_to_list(dirlist, dir):
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
"""Add the directory 'dir' to the list 'dirlist' (after any relative
directories) if:
1) 'dir' is not already in 'dirlist'
2) 'dir' actually exists, and is a directory."""
if dir is not None and os.path.isdir(dir) and dir not in dirlist:
dirlist.insert(0, dir)
2) 'dir' actually exists, and is a directory.
"""
if dir is None or not os.path.isdir(dir) or dir in dirlist:
return
for i, path in enumerate(dirlist):
if not os.path.isabs(path):
dirlist.insert(i + 1, dir)
break

def macosx_sdk_root():
"""
Expand Down Expand Up @@ -362,7 +369,9 @@ def get_platform(self):
return sys.platform

def detect_modules(self):
# Ensure that /usr/local is always used
# Ensure that /usr/local is always used, but the local build
# directories (i.e. '.' and 'Include') must be first. See issue
# 10520.
add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')

Expand Down Expand Up @@ -437,9 +446,10 @@ def detect_modules(self):
# This should work on any unixy platform ;-)
# If the user has bothered specifying additional -I and -L flags
# in OPT and LDFLAGS we might as well use them here.
# NOTE: using shlex.split would technically be more correct, but
# also gives a bootstrap problem. Let's hope nobody uses directories
# with whitespace in the name to store libraries.
#
# NOTE: using shlex.split would technically be more correct, but
# also gives a bootstrap problem. Let's hope nobody uses
# directories with whitespace in the name to store libraries.
cflags, ldflags = sysconfig.get_config_vars(
'CFLAGS', 'LDFLAGS')
for item in cflags.split():
Expand Down

0 comments on commit 807bd0a

Please sign in to comment.