Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 56 additions & 3 deletions recipes/python/patches/Python-2.7.2-ctypes-disable-wchar.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff -uNr Python-2.7.2.orig/Lib/ctypes/__init__.py Python-2.7.2/Lib/ctypes/__init__.py
--- Python-2.7.2.orig/Lib/ctypes/__init__.py 2011-06-11 17:46:24.000000000 +0200
+++ Python-2.7.2/Lib/ctypes/__init__.py 2012-08-30 13:40:38.837698797 +0200
diff -ur '--exclude=*~' Python-2.7.2.orig/Lib/ctypes/__init__.py Python-2.7.2/Lib/ctypes/__init__.py
--- Python-2.7.2.orig/Lib/ctypes/__init__.py 2011-06-11 16:46:24.000000000 +0100
+++ Python-2.7.2/Lib/ctypes/__init__.py 2015-03-19 12:32:45.747723687 +0000
@@ -272,31 +272,34 @@
else:
set_conversion_mode("ascii", "strict")
Expand Down Expand Up @@ -61,3 +61,56 @@ diff -uNr Python-2.7.2.orig/Lib/ctypes/__init__.py Python-2.7.2/Lib/ctypes/__ini

POINTER(c_char).from_param = c_char_p.from_param #_SimpleCData.c_char_p_from_param

diff -ur '--exclude=*~' Python-2.7.2.orig/Modules/_ctypes/callproc.c Python-2.7.2/Modules/_ctypes/callproc.c
--- Python-2.7.2.orig/Modules/_ctypes/callproc.c 2015-03-19 11:56:40.668159317 +0000
+++ Python-2.7.2/Modules/_ctypes/callproc.c 2015-03-19 11:45:45.898288000 +0000
@@ -1423,7 +1423,7 @@
mode |= RTLD_NOW;
handle = ctypes_dlopen(name, mode);
if (!handle) {
- char *errmsg = ctypes_dlerror();
+ const char *errmsg = ctypes_dlerror();
if (!errmsg)
errmsg = "dlopen() error";
PyErr_SetString(PyExc_OSError,
diff -ur '--exclude=*~' Python-2.7.2.orig/Modules/_ctypes/libffi/src/dlmalloc.c Python-2.7.2/Modules/_ctypes/libffi/src/dlmalloc.c
--- Python-2.7.2.orig/Modules/_ctypes/libffi/src/dlmalloc.c 2015-03-19 13:26:58.928438829 +0000
+++ Python-2.7.2/Modules/_ctypes/libffi/src/dlmalloc.c 2015-03-19 15:32:19.042396376 +0000
@@ -614,18 +614,6 @@
#include "/usr/include/malloc.h"
#else /* HAVE_USR_INCLUDE_MALLOC_H */

-struct mallinfo {
- MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */
- MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */
- MALLINFO_FIELD_TYPE smblks; /* always 0 */
- MALLINFO_FIELD_TYPE hblks; /* always 0 */
- MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */
- MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */
- MALLINFO_FIELD_TYPE fsmblks; /* always 0 */
- MALLINFO_FIELD_TYPE uordblks; /* total allocated space */
- MALLINFO_FIELD_TYPE fordblks; /* total free space */
- MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */
-};

#endif /* HAVE_USR_INCLUDE_MALLOC_H */
#endif /* NO_MALLINFO */
@@ -966,7 +954,7 @@
p = malloc(n);
assert(malloc_usable_size(p) >= 256);
*/
-size_t dlmalloc_usable_size(void*);
+size_t dlmalloc_usable_size(const void*);

/*
malloc_stats();
@@ -4384,7 +4372,7 @@
internal_malloc_stats(gm);
}

-size_t dlmalloc_usable_size(void* mem) {
+size_t dlmalloc_usable_size(const void* mem) {
if (mem != 0) {
mchunkptr p = mem2chunk(mem);
if (cinuse(p))

28 changes: 28 additions & 0 deletions recipes/python/patches/ctypes-find-library.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff -ur Python-2.7.2.orig/Lib/ctypes/util.py Python-2.7.2/Lib/ctypes/util.py
--- Python-2.7.2.orig/Lib/ctypes/util.py 2011-06-11 16:46:24.000000000 +0100
+++ Python-2.7.2/Lib/ctypes/util.py 2015-05-10 15:50:18.906203529 +0100
@@ -71,7 +71,21 @@
def find_library(name):
return name

-if os.name == "posix" and sys.platform == "darwin":
+# this test is for android specifically shoudl match here and ignore any
+# of the other platform tests below
+if os.name == "posix":
+ def find_library(name):
+ """ hack to find librarys for kivy and android
+ split the path and get the first parts which will give us
+ the app path something like /data/data/org.app.foo/"""
+ app_root = os.path.abspath('./').split(os.path.sep)[0:4]
+ lib_search = os.path.sep.join(app_root) + os.path.sep + 'lib'
+ for filename in os.listdir(lib_search):
+ if filename.endswith('.so') and name in filename:
+ return lib_search + os.path.sep + filename
+ return None
+
+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,
Only in Python-2.7.2/Lib/ctypes: util.py.save
Only in Python-2.7.2/Lib/ctypes: util.py.save.1
5 changes: 3 additions & 2 deletions recipes/python/recipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function prebuild_python() {
try patch -p1 < $RECIPE_python/patches/fix-remove-corefoundation.patch
try patch -p1 < $RECIPE_python/patches/fix-dynamic-lookup.patch
try patch -p1 < $RECIPE_python/patches/fix-dlfcn.patch
try patch -p1 < $RECIPE_python/patches/ctypes-find-library.patch

system=$(uname -s)
if [ "X$system" == "XDarwin" ]; then
Expand Down Expand Up @@ -94,7 +95,7 @@ function build_python() {
fi

# CFLAGS for python ctypes library
export CFLAGS="$CFLAGS -DNO_MALLINFO"
#export CFLAGS="$CFLAGS -DNO_MALLINFO"
export BUILDARCH=x86_64-linux-gnu
export HOSTARCH=arm-eabi

Expand All @@ -105,7 +106,7 @@ function build_python() {

# FIXME, the first time, we got a error at:
# python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h
# /home/tito/code/python-for-android/build/python/Python-2.7.2/python: 1: Syntax error: word unexpected (expecting ")")
# /home/tito/code/python-for-android/build/python/Python-2.7.2/python: 1: Syntax error: word unexpected (expecting ")")
# because at this time, python is arm, not x86. even that, why /usr/include/netinet/in.h is used ?
# check if we can avoid this part.

Expand Down
9 changes: 7 additions & 2 deletions src/src/org/renpy/android/PythonService.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ public void run(){
System.loadLibrary("python2.7");
System.loadLibrary("application");
System.loadLibrary("sdl_main");
System.loadLibrary("ctypes");

System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_io.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/unicodedata.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_ctypes.so");

try {
System.loadLibrary("ctypes");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_ctypes.so");
} catch(UnsatisfiedLinkError e) {
}

try {
System.loadLibrary("sqlite3");
Expand Down