Skip to content

Commit 539a31a

Browse files
author
Oliver Marks
committed
patch file
1 parent a60d9e6 commit 539a31a

File tree

4 files changed

+117
-4
lines changed

4 files changed

+117
-4
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#https://groups.google.com/forum/?hl=en#!searchin/python-android/ctypes/python-android/vDaaJXNYz_A/eazMVI-DQSYJ
22
#/home/oly/.buildozer/android/platform/
33

4-
export ANDROIDSDK="/home/omarks/.buildozer/android/platform/android-sdk-20"
4+
export ANDROIDSDK="/home/omarks/.buildozer/android/platform/android-sdk-21"
55
export ANDROIDNDK="/home/omarks/.buildozer/android/platform/android-ndk-r9d"
66
export ANDROIDNDKVER=r9
77
export ANDROIDAPI=14

python-for-android-fix_ctypes.diff

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
diff -uNr kivy-python-for-android-51f8025/recipes/python/patches/disable-modules.patch kivy-python-for-android-51f8025-patched6/recipes/python/patches/disable-modules.patch
2+
--- kivy-python-for-android-51f8025/recipes/python/patches/disable-modules.patch 2012-08-24 15:23:07.000000000 +0200
3+
+++ kivy-python-for-android-51f8025-patched6/recipes/python/patches/disable-modules.patch 2012-08-29 14:54:40.000000000 +0200
4+
@@ -5,7 +5,7 @@
5+
6+
# This global variable is used to hold the list of modules to be disabled.
7+
-disabled_module_list = []
8+
-+disabled_module_list = ['spwd', '_ctypes','bz2','ossaudiodev','_curses','_curses_panel','readline','_locale','_bsddb','gdbm','dbm','nis','linuxaudiodev','crypt','_multiprocessing']
9+
++disabled_module_list = ['spwd','bz2','ossaudiodev','_curses','_curses_panel','readline','_locale','_bsddb','gdbm','dbm','nis','linuxaudiodev','crypt','_multiprocessing']
10+
11+
def add_dir_to_list(dirlist, dir):
12+
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
13+
diff -uNr kivy-python-for-android-51f8025/recipes/python/patches/Python-2.7.2-ctypes-disable-wchar.patch kivy-python-for-android-51f8025-patched6/recipes/python/patches/Python-2.7.2-ctypes-disable-wchar.patch
14+
--- kivy-python-for-android-51f8025/recipes/python/patches/Python-2.7.2-ctypes-disable-wchar.patch 1970-01-01 01:00:00.000000000 +0100
15+
+++ kivy-python-for-android-51f8025-patched6/recipes/python/patches/Python-2.7.2-ctypes-disable-wchar.patch 2012-08-30 13:41:33.000000000 +0200
16+
@@ -0,0 +1,63 @@
17+
+diff -uNr Python-2.7.2.orig/Lib/ctypes/__init__.py Python-2.7.2/Lib/ctypes/__init__.py
18+
+--- Python-2.7.2.orig/Lib/ctypes/__init__.py 2011-06-11 17:46:24.000000000 +0200
19+
++++ Python-2.7.2/Lib/ctypes/__init__.py 2012-08-30 13:40:38.837698797 +0200
20+
+@@ -272,31 +272,34 @@
21+
+ else:
22+
+ set_conversion_mode("ascii", "strict")
23+
+
24+
+- class c_wchar_p(_SimpleCData):
25+
+- _type_ = "Z"
26+
+-
27+
+- class c_wchar(_SimpleCData):
28+
+- _type_ = "u"
29+
+-
30+
+- POINTER(c_wchar).from_param = c_wchar_p.from_param #_SimpleCData.c_wchar_p_from_param
31+
+-
32+
+- def create_unicode_buffer(init, size=None):
33+
+- """create_unicode_buffer(aString) -> character array
34+
+- create_unicode_buffer(anInteger) -> character array
35+
+- create_unicode_buffer(aString, anInteger) -> character array
36+
+- """
37+
+- if isinstance(init, (str, unicode)):
38+
+- if size is None:
39+
+- size = len(init)+1
40+
+- buftype = c_wchar * size
41+
+- buf = buftype()
42+
+- buf.value = init
43+
+- return buf
44+
+- elif isinstance(init, (int, long)):
45+
+- buftype = c_wchar * init
46+
+- buf = buftype()
47+
+- return buf
48+
+- raise TypeError(init)
49+
++# The wchar stuff causes a crash on Android (the bionic C library doesn't
50+
++# implement wchar_t anyway)
51+
++#
52+
++# class c_wchar_p(_SimpleCData):
53+
++# _type_ = "Z"
54+
++#
55+
++# class c_wchar(_SimpleCData):
56+
++# _type_ = "u"
57+
++#
58+
++# POINTER(c_wchar).from_param = c_wchar_p.from_param #_SimpleCData.c_wchar_p_from_param
59+
++#
60+
++# def create_unicode_buffer(init, size=None):
61+
++# """create_unicode_buffer(aString) -> character array
62+
++# create_unicode_buffer(anInteger) -> character array
63+
++# create_unicode_buffer(aString, anInteger) -> character array
64+
++# """
65+
++# if isinstance(init, (str, unicode)):
66+
++# if size is None:
67+
++# size = len(init)+1
68+
++# buftype = c_wchar * size
69+
++# buf = buftype()
70+
++# buf.value = init
71+
++# return buf
72+
++# elif isinstance(init, (int, long)):
73+
++# buftype = c_wchar * init
74+
++# buf = buftype()
75+
++# return buf
76+
++# raise TypeError(init)
77+
+
78+
+ POINTER(c_char).from_param = c_char_p.from_param #_SimpleCData.c_char_p_from_param
79+
+
80+
diff -uNr kivy-python-for-android-51f8025/recipes/python/patches/Python-2.7.2-xcompile.patch kivy-python-for-android-51f8025-patched6/recipes/python/patches/Python-2.7.2-xcompile.patch
81+
--- kivy-python-for-android-51f8025/recipes/python/patches/Python-2.7.2-xcompile.patch 2012-08-24 15:23:07.000000000 +0200
82+
+++ kivy-python-for-android-51f8025-patched6/recipes/python/patches/Python-2.7.2-xcompile.patch 2012-08-30 15:51:37.000000000 +0200
83+
@@ -181,10 +181,10 @@
84+
- cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
85+
- % (ffi_builddir, ffi_srcdir, " ".join(config_args))
86+
+ if self.cross_compile:
87+
-+ cmd = "cd %s && env CFLAGS='' %s/configure --host=%s --build=%s %s" \
88+
++ cmd = "cd %s && env CFLAGS='-DNO_MALLINFO=1 -DFFI_MMAP_EXEC_WRIT=1 -DFFI_MMAP_EXEC_SELINUX=0' %s/configure --host=%s --build=%s %s" \
89+
+ % (ffi_builddir, ffi_srcdir,
90+
-+ os.environ.get('HOSTARCH'),
91+
-+ os.environ.get('BUILDARCH'),
92+
++ 'arm-eabi',
93+
++ 'i486-linux-gnu',
94+
+ " ".join(config_args))
95+
+ else:
96+
+ cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
97+
diff -uNr kivy-python-for-android-51f8025/recipes/python/recipe.sh kivy-python-for-android-51f8025-patched6/recipes/python/recipe.sh
98+
--- kivy-python-for-android-51f8025/recipes/python/recipe.sh 2012-08-24 15:23:07.000000000 +0200
99+
+++ kivy-python-for-android-51f8025-patched6/recipes/python/recipe.sh 2012-08-30 14:24:47.000000000 +0200
100+
@@ -19,6 +19,7 @@
101+
fi
102+
103+
try patch -p1 < $RECIPE_python/patches/Python-$VERSION_python-xcompile.patch
104+
+ try patch -p1 < $RECIPE_python/patches/Python-$VERSION_python-ctypes-disable-wchar.patch
105+
try patch -p1 < $RECIPE_python/patches/disable-modules.patch
106+
try patch -p1 < $RECIPE_python/patches/fix-locale.patch
107+
try patch -p1 < $RECIPE_python/patches/fix-gethostbyaddr.patch

recipes/python/recipe.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ function build_python() {
9595

9696
# CFLAGS for python ctypes library
9797
export CFLAGS="$CFLAGS -DNO_MALLINFO"
98+
export BUILDARCH=x86_64-linux-gnu
99+
export HOSTARCH=arm-eabi
98100

99-
100-
try ./configure --host=arm-eabi OPT=$OFLAG --prefix="$BUILD_PATH/python-install" --enable-shared --disable-toolbox-glue --disable-framework
101-
echo ./configure --host=arm-eabi OPT=$OFLAG --prefix="$BUILD_PATH/python-install" --enable-shared --disable-toolbox-glue --disable-framework
101+
try ./configure --host=$HOSTARCH --build=$BUILDARCH OPT=$OFLAG --prefix="$BUILD_PATH/python-install" --enable-shared --disable-toolbox-glue --disable-framework
102+
echo ./configure --host=$HOSTARCH --build=$BUILDARCH OPT=$OFLAG --prefix="$BUILD_PATH/python-install" --enable-shared --disable-toolbox-glue --disable-framework
102103
echo $MAKE HOSTPYTHON=$BUILD_python/hostpython HOSTPGEN=$BUILD_python/hostpgen CROSS_COMPILE_TARGET=yes INSTSONAME=libpython2.7.so
103104
cp HOSTPYTHON=$BUILD_python/hostpython python
104105

@@ -126,8 +127,10 @@ function build_python() {
126127
echo '############copy ctypes'
127128
cd $BUILD_python
128129
echo $BUILD_python
130+
echo pwd
129131
echo build/lib.linux-x86_64-2.7/_ctypes*.so
130132
try cp -a build/lib.linux-x86_64-2.7/_ctypes*.so $LIBS_PATH
133+
#exit 0
131134

132135
# reduce python
133136
rm -rf "$BUILD_PATH/python-install/lib/python2.7/test"

src/src/org/renpy/android/PythonService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ public void run(){
8989
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_io.so");
9090
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/unicodedata.so");
9191

92+
System.loadLibrary("ctypes");
93+
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_ctypes.so");
94+
9295
try {
9396
System.loadLibrary("sqlite3");
9497
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_sqlite3.so");

0 commit comments

Comments
 (0)