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

Skip to content

Commit 39230b3

Browse files
author
Michael W. Hudson
committed
Apply a variant of patch
[ #420565 ] makes setup.py search sys.prefix I think this also fixes some bug in the tracker about not searching directories that don't exist, but I can't find the report :(
1 parent 8f51460 commit 39230b3

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

setup.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
# This global variable is used to hold the list of modules to be disabled.
1515
disabled_module_list = []
1616

17+
def add_dir_to_list(dirlist, dir):
18+
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
19+
1) 'dir' is not already in 'dirlist'
20+
2) 'dir' actually exists, and is a directory."""
21+
if os.path.isdir(dir) and dir not in dirlist:
22+
dirlist.insert(0, dir)
23+
1724
def find_file(filename, std_dirs, paths):
1825
"""Searches for the directory where a given file is located,
1926
and returns a possibly-empty list of additional directories, or None
@@ -193,10 +200,13 @@ def get_platform (self):
193200

194201
def detect_modules(self):
195202
# Ensure that /usr/local is always used
196-
if '/usr/local/lib' not in self.compiler.library_dirs:
197-
self.compiler.library_dirs.insert(0, '/usr/local/lib')
198-
if '/usr/local/include' not in self.compiler.include_dirs:
199-
self.compiler.include_dirs.insert(0, '/usr/local/include' )
203+
add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
204+
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
205+
206+
add_dir_to_list(self.compiler.library_dirs,
207+
sysconfig.get_config_var("LIBDIR"))
208+
add_dir_to_list(self.compiler.include_dirs,
209+
sysconfig.get_config_var("INCLUDEDIR"))
200210

201211
try:
202212
have_unicode = unicode

0 commit comments

Comments
 (0)