From: Andrei Tatar Date: Tue, 29 Aug 2023 00:03:58 +0000 (+0200) Subject: patches: Fix ctypes import error X-Git-Tag: RELEASE-0.15.0~4 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a5f8ef1f0a8a7b5a0c982b33b7de01eec330afa0;p=unikraft%2Flibs%2Fpython3.git patches: Fix ctypes import error This change adds a patch that allows ctypes to be imported by ignoring a failing PyDLL() call (which is not supported under Unikraft due to lack of dynamic linking). Signed-off-by: Andrei Tatar Reviewed-by: Maria Sfiraiala Reviewed-by: Radu Nichita Approved-by: Razvan Deaconescu GitHub-Closes: #18 --- diff --git a/patches/0004-Ignore-failure-to-load-python-lib-via-ctypes.patch b/patches/0004-Ignore-failure-to-load-python-lib-via-ctypes.patch new file mode 100644 index 0000000..48991b8 --- /dev/null +++ b/patches/0004-Ignore-failure-to-load-python-lib-via-ctypes.patch @@ -0,0 +1,29 @@ +From 09b17896ac450cd119401eff5c60a53fbd8abb0e Mon Sep 17 00:00:00 2001 +From: Andrei Tatar +Date: Thu, 20 Jul 2023 16:09:08 +0200 +Subject: [PATCH 4/4] Ignore failure to load python lib via ctypes + +Signed-off-by: Andrei Tatar +--- + Lib/ctypes/__init__.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py +index 4afa4ebd42..67f6ad4006 100644 +--- a/Lib/ctypes/__init__.py ++++ b/Lib/ctypes/__init__.py +@@ -461,7 +461,10 @@ def LoadLibrary(self, name): + elif _sys.platform == "cygwin": + pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2]) + else: +- pythonapi = PyDLL(None) ++ try: ++ pythonapi = PyDLL(None) ++ except OSError: ++ pass + + + if _os.name == "nt": +-- +2.41.0 +