summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2024-03-19 12:36:19 (GMT)
committerGitHub <noreply@github.com>2024-03-19 12:36:19 (GMT)
commit408e127159e54d87bb3464fd8bd60219dc527fac (patch)
tree055bc39042521f314a7d225a22b3ca8ce403d453 /Lib/ctypes
parenta5574789876987b2b9aa19294c735fe795a5b5c4 (diff)
downloadcpython-408e127159e54d87bb3464fd8bd60219dc527fac.zip
cpython-408e127159e54d87bb3464fd8bd60219dc527fac.tar.gz
cpython-408e127159e54d87bb3464fd8bd60219dc527fac.tar.bz2
gh-114099 - Add iOS framework loading machinery. (GH-116454)
Co-authored-by: Malcolm Smith <smith@chaquo.com> Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Diffstat (limited to 'Lib/ctypes')
-rw-r--r--Lib/ctypes/__init__.py11
-rw-r--r--Lib/ctypes/util.py2
2 files changed, 12 insertions, 1 deletions
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
index f63e31a..36b2af7 100644
--- a/Lib/ctypes/__init__.py
+++ b/Lib/ctypes/__init__.py
@@ -348,6 +348,17 @@ class CDLL(object):
winmode=None):
if name:
name = _os.fspath(name)
+
+ # If the filename that has been provided is an iOS/tvOS/watchOS
+ # .fwork file, dereference the location to the true origin of the
+ # binary.
+ if name.endswith(".fwork"):
+ with open(name) as f:
+ name = _os.path.join(
+ _os.path.dirname(_sys.executable),
+ f.read().strip()
+ )
+
self._name = name
flags = self._func_flags_
if use_errno:
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index c550883..12d7428 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -67,7 +67,7 @@ if os.name == "nt":
return fname
return None
-elif os.name == "posix" and sys.platform == "darwin":
+elif os.name == "posix" and sys.platform in {"darwin", "ios", "tvos", "watchos"}:
from ctypes.macholib.dyld import dyld_find as _dyld_find
def find_library(name):
possible = ['lib%s.dylib' % name,