diff -r 4401f56cc761 Lib/ctypes/util.py --- a/Lib/ctypes/util.py Fri Feb 18 02:34:28 2011 +0100 +++ b/Lib/ctypes/util.py Sun Feb 20 17:28:58 2011 +0100 @@ -203,14 +203,17 @@ elif os.name == "posix": abi_type = mach_map.get(machine, 'libc6') # XXX assuming GLIBC's ldconfig (with option -p) - expr = r'(\S+)\s+\((%s(?:, OS ABI:[^\)]*)?)\)[^/]*(/[^\(\)\s]*lib%s\.[^\(\)\s]*)' \ - % (abi_type, re.escape(name)) + name = 'lib%s' % name with contextlib.closing(os.popen('LC_ALL=C LANG=C /sbin/ldconfig -p 2>/dev/null')) as f: - data = f.read() - res = re.search(expr, data) - if not res: - return None - return res.group(1) + for line in f: + if not '=>' in line: + continue + path = line.rsplit('=>', 1)[1] + if not name+'.' in path: + continue + res = re.search('\s*(/[^\(\)\s]*%s\.[^\(\)\s]*)' % name, path) + if res: + return res.group(1) def find_library(name): return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name))