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

Skip to content

Commit a246d9f

Browse files
committed
[Patch #641685] setup.py contained code for finding libraries, instead
of using the CCompiler.find_library_file() provided by the Distutils. This patch fixes it to use the Distutils method at the cost of some additional glue. (The duplication resulted in the SSL module not being automatically built on Macs; the Distutils knew that shared libraries on OS X have a .dylib extension, but the setup.py code didn't.)
1 parent d680a86 commit a246d9f

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

setup.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,30 @@ def find_file(filename, std_dirs, paths):
4848
return None
4949

5050
def find_library_file(compiler, libname, std_dirs, paths):
51-
filename = compiler.library_filename(libname, lib_type='shared')
52-
result = find_file(filename, std_dirs, paths)
53-
if result is not None: return result
54-
55-
filename = compiler.library_filename(libname, lib_type='static')
56-
result = find_file(filename, std_dirs, paths)
57-
return result
58-
51+
result = compiler.find_library_file(std_dirs + paths, libname)
52+
if result is None:
53+
return None
54+
55+
# Check whether the found file is in one of the standard directories
56+
dirname = os.path.dirname(result)
57+
for p in std_dirs:
58+
# Ensure path doesn't end with path separator
59+
if p.endswith(os.sep):
60+
p = p.strip(os.sep)
61+
if p == dirname:
62+
return [ ]
63+
64+
# Otherwise, it must have been in one of the additional directories,
65+
# so we have to figure out which one.
66+
for p in paths:
67+
# Ensure path doesn't end with path separator
68+
if p.endswith(os.sep):
69+
p = p.strip(os.sep)
70+
if p == dirname:
71+
return [p]
72+
else:
73+
assert False, "Internal error: Path not found in std_dirs or paths"
74+
5975
def module_enabled(extlist, modname):
6076
"""Returns whether the module 'modname' is present in the list
6177
of extensions 'extlist'."""

0 commit comments

Comments
 (0)