8000 Merge pull request #1624 from JonasT/fix_ctypes_util · kivy/python-for-android@0b71851 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0b71851

Browse files
authored
Merge pull request #1624 from JonasT/fix_ctypes_util
Fix ctypes.util.find_library() not finding any libraries on Android
2 parents f52cfc3 + b6b5cc5 commit 0b71851

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

pythonforandroid/recipes/python3/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class Python3Recipe(GuestPythonRecipe):
2121
url = 'https://www.python.org/ftp/python/{version}/Python-{version}.tgz'
2222
name = 'python3'
2323

24+
patches = ["patches/fix-ctypes-util-find-library.patch"]
25+
2426
depends = ['hostpython3']
2527
conflicts = ['python3crystax', 'python2', 'python2legacy']
2628

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
2+
--- a/Lib/ctypes/util.py
3+
+++ b/Lib/ctypes/util.py
4+
@@ -67,4 +67,19 @@
5+
return fname
6+
return None
7+
8+
+# This patch overrides the find_library to look in the right places on
9+
+# Android
10+
+if True:
11+
+ def find_library(name):
12+
+ # Check the user app libs and system libraries directory:
13+
+ app_root = os.path.normpath(os.path.abspath('../../'))
14+
+ lib_search_dirs = [os.path.join(app_root, 'lib'), "/system/lib"]
15+
+ for lib_dir in lib_search_dirs:
16+
+ for filename in os.listdir(lib_dir):
17+
+ if filename.endswith('.so') and (
18+
+ filename.startswith("lib" + name + ".") or
19+
+ filename.startswith(name + ".")):
20+
+ return os.path.join(lib_dir, filename)
21+
+ return None
22+
+
23+
elif os.name == "posix" and sys.platform == "darwin":

0 commit comments

Comments
 (0)
0