diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index 01176bf9696577..ca90f97600e640 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -70,15 +70,25 @@ def find_library(name): elif os.name == "posix" and sys.platform == "darwin": from ctypes.macholib.dyld import dyld_find as _dyld_find def find_library(name): - possible = ['lib%s.dylib' % name, - '%s.dylib' % name, - '%s.framework/%s' % (name, name)] - for name in possible: - try: - return _dyld_find(name) - except ValueError: - continue - return None + from platform import mac_ver + macos_version = mac_ver()[0] + if macos_version == '10.16' or macos_version == '11.0': + # see https://bugs.python.org/issue41179 + # macOS Big Sur no longer copies dynamic libraries + # TODO (@sumanthratna): we shouldn't change this logic + # https://github.com/python/cpython/blob/0a2ee77547c0e25f081cfb6507a1ab8fecbd683a/Lib/ctypes/macholib/dyld.py#L15-L29 + # this probably requires a change to ctypes.macholib.dyld.dyld_find + pass + else: + possible = ['lib%s.dylib' % name, + '%s.dylib' % name, + '%s.framework/%s' % (name, name)] + for name in possible: + try: + return _dyld_find(name) + except ValueError: + continue + return None elif sys.platform.startswith("aix"): # AIX has two styles of storing shared libraries