Skip to content

Commit a98c9a6

Browse files
committed
Added updated ctypes find_library patch
1 parent 4cf5ca8 commit a98c9a6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
2+
index 52b3520..01b13a9 100644
3+
--- a/Lib/ctypes/util.py
4+
+++ b/Lib/ctypes/util.py
5+
@@ -71,7 +71,23 @@ if os.name == "ce":
6+
def find_library(name):
7+
return name
8+
9+
-if os.name == "posix" and sys.platform == "darwin":
10+
+# This patch overrides the find_library to look in the right places on
11+
+# Android
12+
+if True:
13+
+ def find_library(name):
14+
+ # Check the user app lib dir
15+
+ app_root = os.path.abspath('./').split(os.path.sep)[0:4]
16+
+ lib_search = os.path.sep.join(app_root) + os.path.sep + 'lib'
17+
+ for filename in os.listdir(lib_search):
18+
+ if filename.endswith('.so') and name in filename:
19+
+ return lib_search + os.path.sep + filename
20+
+ # Check the normal Android system libraries
21+
+ for filename in os.listdir('/system/lib'):
22+
+ if filename.endswith('.so') and name in filename:
23+
+ return lib_search + os.path.sep + filename
24+
+ return None
25+
+
26+
+elif os.name == "posix" and sys.platform == "darwin":
27+
from ctypes.macholib.dyld import dyld_find as _dyld_find
28+
def find_library(name):
29+
possible = ['lib%s.dylib' % name,

0 commit comments

Comments
 (0)