Skip to content

Commit

Permalink
Merge pull request #1877 from surbhicis/py2-ctypes-fixes
Browse files Browse the repository at this point in the history
fix ctypes-util-find-library issue for python2
  • Loading branch information
AndreMiras committed Jun 21, 2019
2 parents 6f99407 + 5795852 commit e494c25
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pythonforandroid/recipes/python2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class Python2Recipe(GuestPythonRecipe):
'patches/fix-filesystem-default-encoding.patch',
'patches/fix-gethostbyaddr.patch',
'patches/fix-posix-declarations.patch',
'patches/fix-pwd-gecos.patch']
'patches/fix-pwd-gecos.patch',
'patches/fix-ctypes-util-find-library.patch']

configure_args = ('--host={android_host}',
'--build={android_build}',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff -u a/Lib/ctypes/util.py b/Lib/ctypes/util.py
--- a/Lib/ctypes/util.py 2019-06-20 18:52:01.372205226 +0200
+++ b/Lib/ctypes/util.py 2019-06-20 18:51:39.612970779 +0200
@@ -70,7 +70,14 @@
def find_library(name):
return name

-if os.name == "posix" and sys.platform == "darwin":
+# This patch overrides the find_library to look in the right places on
+# Android
+if True:
+ from android._ctypes_library_finder import find_library as _find_lib
+ def find_library(name):
+ return _find_lib(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,

0 comments on commit e494c25

Please sign in to comment.