diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index 1881e89..3ce5ab0 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -203,14 +203,11 @@ 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)) + regex = '\s+(lib%s\.[^\s]+)\s+\(%s' % (re.escape(name), abi_type) 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) + res = re.search(regex, f.read()) + if res: + return res.group(1) def find_library(name): return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name))