8000 Updates the python's recipe to version 2.7.11 · opacam/python-for-android@848fe2e · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit 848fe2e

Browse files
author
Pol Canelles
committed
Updates the python's recipe to version 2.7.11
1 parent 52f2478 commit 848fe2e

28 files changed

+2649
-947
lines changed

pythonforandroid/bootstraps/pygame/build/jni/Application.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ APP_PROJECT_PATH := $(call my-dir)/..
55
# sdl_image depends on png and jpeg
66
# sdl_ttf depends on freetype
77

8-
APP_MODULES := application sdl sdl_main tremor png jpeg freetype sdl_ttf sdl_image sqlite3
8+
APP_MODULES := application sdl sdl_main tremor png jpeg freetype sdl_ttf sdl_image
99

1010
APP_ABI := $(ARCH)
1111
# AND: I have no idea why I have to specify app_platform when distribute.sh seems to just set the sysroot cflag

pythonforandroid/bootstraps/pygame/build/src/org/renpy/android/PythonActivity.java

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@
4545
public class PythonActivity extends Activity implements Runnable {
4646
private static String TAG = "Python";
4747

48+
// The libraries
49+
protected static String[] getLibraries() {
50+
return new String[] {
51+
"sdl",
52+
2D08 "sdl_image",
53+
"sdl_ttf",
54+
"sdl_mixer",
55+
"sqlite3",
56+
"ffi",
57+
"python2.7",
58+
"application",
59+
"sdl_main",
60+
};
61+
}
62+
63+
4864
// The audio thread for streaming audio...
4965
private static AudioThread mAudioThread = null;
5066

@@ -247,30 +263,25 @@ public void run() {
247263
unpackData("private", getFilesDir());
248264
unpackData("public", externalStorage);
249265

250-
System.loadLibrary("sdl");
251-
System.loadLibrary("sdl_image");
252-
System.loadLibrary("sdl_ttf");
253-
System.loadLibrary("sdl_mixer");
254-
System.loadLibrary("python2.7");
255-
System.loadLibrary("application");
256-
System.loadLibrary("sdl_main");
266+
for (String lib : getLibraries()) {
267+
try {
268+
System.loadLibrary(lib);
269+
} catch(UnsatisfiedLinkError e) {
270+
if (lib.startsWith("sqlite3")) {
271+
Log.i("python", "Failed to load lib" + lib + ".so, but that's okay, it's an optional library");
272+
continue;
273+
}
274+
if (lib.startsWith("ffi")) {
275+
Log.i("python", "Failed to load lib" + lib + ".so, but that's okay, it's an optional library");
276+
continue;
277+
}
278+
throw e;
279+
}
280+
}
257281

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

261-
try {
262-
System.loadLibrary("sqlite3");
263-
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_sqlite3.so");
264-
} catch(UnsatisfiedLinkError e) {
265-
}
266-
267-
try {
268-
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imaging.so");
269-
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingft.so");
270-
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingmath.so");
271-
} catch(UnsatisfiedLinkError e) {
272-
}
273-
274285
if ( mAudioThread == null ) {
275286
Log.i("python", "Starting audio thread");
276287
mAudioThread = new AudioThread(this);

pythonforandroid/bootstraps/pygame/build/src/org/renpy/android/PythonService.java

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212

1313
public class PythonService extends Service implements Runnable {
1414

15+
// The libraries
16+
protected static String[] getLibraries() {
17+
return new String[] {
18+
"sdl",
19+
"sdl_image",
20+
"sdl_ttf",
21+
"sdl_mixer",
22+
"sqlite3",
23+
"ffi",
24+
"python2.7",
25+
"application",
26+
"sdl_main",
27+
};
28+
}
29+
1530
// Thread for Python code
1631
private Thread pythonThread = null;
1732

@@ -78,30 +93,25 @@ public void onDestroy() {
7893
public void run(){
7994

8095
// libraries loading, the same way PythonActivity.run() do
81-
System.loadLibrary("sdl");
82-
System.loadLibrary("sdl_image");
83-
System.loadLibrary("sdl_ttf");
84-
System.loadLibrary("sdl_mixer");
85-
System.loadLibrary("python2.7");
86-
System.loadLibrary("application");
87-
System.loadLibrary("sdl_main");
96+
for (String lib : getLibraries()) {
97+
try {
98+
System.loadLibrary(lib);
99+
} catch(UnsatisfiedLinkError e) {
100+
if (lib.startsWith("sqlite3")) {
101+
Log.i("python", "Failed to load lib" + lib + ".so, but that's okay, it's an optional library");
102+
continue;
103+
}
104+
if (lib.startsWith("ffi")) {
105+
Log.i("python", "Failed to load lib" + lib + ".so, but that's okay, it's an optional library");
106+
continue;
107+
}
108+
throw e;
109+
}
110+
}
88111

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

92-
try {
93-
System.loadLibrary("sqlite3");
94-
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_sqlite3.so");
95-
} catch(UnsatisfiedLinkError e) {
96-
}
97-
98-
try {
99-
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imaging.so");
100-
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingft.so");
101-
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingmath.so");
102-
} catch(UnsatisfiedLinkError e) {
103-
}
104-
105115
this.mService = this;
106116
nativeInitJavaEnv();
107117
nativeStart(androidPrivate, androidArgument, pythonHome, pythonPath,

pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonUtil.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ protected static String[] getLibraries() {
1414
"SDL2_image",
1515
"SDL2_mixer",
1616
"SDL2_ttf",
17+
"sqlite3",
18+
"ffi",
1719
"python2.7",
1820
"python3.5m",
1921
"main"
@@ -33,6 +35,14 @@ public static void loadLibraries(File filesDir) {
3335
skippedPython = true;
3436
continue;
3537
}
38+
if (lib.startsWith("sqlite3")) {
39+
Log.v(TAG, "Failed to load lib" + lib + ".so, but that's okay, it's an optional library");
40+
continue;
41+
}
42+
if (lib.startsWith("ffi")) {
43+
Log.v(TAG, "Failed to load lib" + lib + ".so, but that's okay, it's an optional library");
44+
continue;
45+
}
3646
throw e;
3747
}
3848
}
@@ -43,13 +53,6 @@ public static void loadLibraries(File filesDir) {
4353
} catch(UnsatisfiedLinkError e) {
4454
Log.v(TAG, "Failed to load _io.so or unicodedata.so...but that's okay.");
4555
}
46-
47-
try {
48-
// System.loadLibrary("ctypes");
49-
System.load(filesDirPath + "/lib/python2.7/lib-dynload/_ctypes.so");
50-
} catch(UnsatisfiedLinkError e) {
51-
Log.v(TAG, "Unsatisfied linker when loading ctypes");
52-
}
5356

5457
Log.v(TAG, "Loaded everything!");
5558
}

pythonforandroid/recipes/hostpython2/Setup

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ PYTHONPATH=$(COREPYTHONPATH)
109109
# various reasons; therefore they are listed here instead of in the
110110
# normal order.
111111

112-
# This only contains the minimal set of modules required to run the
112+
# This only contains the minimal set of modules required to run the
113113
# setup.py script in the root of the Python source tree.
114114

115115
posix posixmodule.c # posix (UNIX) system calls
@@ -118,6 +118,7 @@ pwd pwdmodule.c # this is needed to find out the user's home dir
118118
# if $HOME is not set
119119
_sre _sre.c # Fredrik Lundh's new regular expressions
120120
_codecs _codecsmodule.c # access to the builtin codecs and codec registry
121+
_weakref _weakref.c # weak references
121122

122123
# The zipimport module is always imported at startup. Having it as a
123124
# builtin module avoids some bootstrapping problems and reduces overhead.
@@ -126,9 +127,9 @@ zipimport zipimport.c
126127
# The rest of the modules listed in this file are all commented out by
127128
# default. Usually they can be detected and built as dynamically
128129
# loaded modules by the new setup.py script added in Python 2.1. If
129-
# you're on a platform that doesn't support dynamic loading, want to
130-
# compile modules statically into the Python binary, or need to
131-
# specify some odd set of compiler switches, you can uncomment the
130+
# you're on a platform that doesn't support dynamic loading, want to
131+
# compile modules statically into the Python binary, or need to
132+
# specify some odd set of compiler switches, you can uncomment the
132133
# appropriate lines below.
133134

134135
# ======================================================================
@@ -168,16 +169,16 @@ GLHACK=-Dclear=__GLclear
168169
# Modules that should always be present (non UNIX dependent):
169170

170171
array arraymodule.c # array objects
171-
cmath cmathmodule.c # -lm # complex math library functions
172-
math mathmodule.c # -lm # math library functions, e.g. sin()
172+
cmath cmathmodule.c _math.c # -lm # complex math library functions
173+
math mathmodule.c # _math.c # -lm # math library functions, e.g. sin()
173174
_struct _struct.c # binary structure packing/unpacking
174175
time timemodule.c # -lm # time operations and variables
175176
operator operator.c # operator.add() and similar goodies
176-
_weakref _weakref.c # basic weak reference support
177177
#_testcapi _testcapimodule.c # Python C API test module
178178
_random _randommodule.c # Random number generator
179179
_collections _collectionsmodule.c # Container types
180-
itertools itertoolsmodule.c # Functions creating iterators for efficient looping
180+
#_heapq _heapqmodule.c # Heapq type
181+
itertools itertoolsmodule.c # Functions creating iterators for efficient looping
181182
strop stropmodule.c # String manipulations
182183
_functools _functoolsmodule.c # Tools for working with functions and callable objects
183184
_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator
@@ -190,13 +191,16 @@ _bisect _bisectmodule.c # Bisection algorithms
190191
# access to ISO C locale support
191192
#_locale _localemodule.c # -lintl
192193

194+
# Standard I/O baseline
195+
#_io -I$(srcdir)/Modules/_io _io/bufferedio.c _io/bytesio.c _io/fileio.c _io/iobase.c _io/_iomodule.c _io/stringio.c _io/textio.c
196+
193197

194198
# Modules with some UNIX dependencies -- on by default:
195199
# (If you have a really backward UNIX, select and socket may not be
196200
# supported...)
197201

198202
fcntl fcntlmodule.c # fcntl(2) and ioctl(2)
199-
#spwd spwdmodule.c # spwd(3)
203+
#spwd spwdmodule.c # spwd(3)
200204
#grp grpmodule.c # grp(3)
201205
select selectmodule.c # select(2); not on ancient System V
202206

@@ -299,7 +303,7 @@ _sha512 sha512module.c
299303
#sunaudiodev sunaudiodev.c
300304

301305

302-
# A Linux specific module -- off by default; this may also work on
306+
# A Linux specific module -- off by default; this may also work on
303307
# some *BSDs.
304308

305309
#linuxaudiodev linuxaudiodev.c
@@ -365,7 +369,7 @@ _sha512 sha512module.c
365369

366370
#_curses _cursesmodule.c -lcurses -ltermcap
367371
# Wrapper for the panel library that's part of ncurses and SYSV curses.
368-
#_curses_panel _curses_panel.c -lpanel -lncurses
372+
#_curses_panel _curses_panel.c -lpanel -lncurses
369373

370374

371375
# Generic (SunOS / SVR4) dynamic loading module.

pythonforandroid/recipes/hostpython2/__init__.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

22
from pythonforandroid.toolchain import Recipe, shprint, current_directory, info, warning
33
from os.path import join, exists
4-
from os import chdir
4+
from os import environ
55
import sh
66

77

88
class Hostpython2Recipe(Recipe):
9-
version = '2.7.2'
10-
url = 'http://python.org/ftp/python/{version}/Python-{version}.tar.bz2'
9+
version = '2.7.11'
10+
url = 'http://python.org/ftp/python/{version}/Python-{version}.tgz'
1111
name = 'hostpython2'
1212

1313
conflicts = ['hostpython3']
@@ -20,26 +20,36 @@ def get_build_container_dir(self, arch=None):
2020
def get_build_dir(self, arch=None):
2121
return join(self.get_build_container_dir(), self.name)
2222

23+
def should_build(self, arch):
24+
if exists(join(self.get_build_dir(), 'hostpython')):
25+
info('Setting ctx hostpython2 from previous build...')
26+
self.ctx.hostpython = join(self.get_build_dir(), 'hostpython')
27+
self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen')
28+
return False
29+
else:
30+
info('Must build hostpython2...')
31+
return True
32+
2333
def prebuild_arch(self, arch):
2434
# Override hostpython Setup?
2535
shprint(sh.cp, join(self.get_recipe_dir(), 'Setup'),
2636
join(self.get_build_dir(), 'Modules', 'Setup'))
2737

2838
def build_arch(self, arch):
39+
env = dict(environ)
2940
with current_directory(self.get_build_dir()):
30-
3141
if exists('hostpython'):
3242
info('hostpython already exists, skipping build')
3343
self.ctx.hostpython = join(self.get_build_dir(),
3444
'hostpython')
3545
self.ctx.hostpgen = join(self.get_build_dir(),
3646
'hostpgen')
3747
return
38-
48+
3949
configure = sh.Command('./configure')
4050

41-
shprint(configure)
42-
shprint(sh.make, '-j5')
51+
shprint(configure, _env=env)
52+
shprint(sh.make, '-j5', _env=env)
4353

4454
shprint(sh.mv, join('Parser', 'pgen'), 'hostpgen')
4555

pythonforandroid/recipes/pygame_bootstrap_components/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from pythonforandroid.toolchain import BootstrapNDKRecipe, current_directory, shprint, info
2-
from os.path import exists, join
1+
from pythonforandroid.toolchain import BootstrapNDKRecipe, current_directory
2+
from pythonforandroid.logger import shprint, info
3+
from os.path import exists, join, basename
34
import sh
45
import glob
56

@@ -19,9 +20,10 @@ def prebuild_arch(self, arch):
1920
return
2021
for dirn in glob.glob(join(self.get_build_dir(arch),
2122
'pygame_bootstrap_jni', '*')):
22-
shprint(sh.mv, dirn, './')
23+
if basename(dirn) not in ['sqlite3']:
24+
shprint(sh.mv, dirn, './')
2325
info('Unpacking was successful, deleting original container dir')
2426
shprint(sh.rm, '-rf', self.get_build_dir(arch))
25-
27+
2628

2729
recipe = PygameJNIComponentsRecipe()

0 commit comments

Comments
 (0)
0