Skip to content

[WIP] bpo-41179: Fix ctypes.util.find_library on macOS Big Sur #21250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions Lib/ctypes/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down