diff -r ae56145f4282 Lib/ctypes/util.py --- a/Lib/ctypes/util.py Tue Jan 04 19:47:17 2011 +0100 +++ b/Lib/ctypes/util.py Sun Feb 20 17:02:22 2011 +0100 @@ -220,17 +220,17 @@ 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)) - f = os.popen('/sbin/ldconfig -p 2>/dev/null') + name = 'lib%s' % name + f = os.popen('/sbin/ldconfig -p 2>/dev/null | grep %s\\\\.' % name) try: data = f.read() finally: f.close() - res = re.search(expr, data) - if not res: - return None - return res.group(1) + for line in data.split('\n'): + path = line.rsplit('=>', 1)[1] + 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))