8000 Python 2.7.11 & Updates (Only for testing purposes) by opacam · Pull Request #693 · kivy/python-for-android · GitHub
[go: up one dir, main page]

Skip to content

Python 2.7.11 & Updates (Only for testing purposes) #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9a30281
Merge pull request #1 from kivy/master
opacam Mar 6, 2016
edef626
Python 2 updated to version 2.7.9
Mar 7, 2016
1206c30
Undo rename openssl x.so files
brussee Mar 15, 2016
2c7e384
add recipes python includes and linker flags
brussee Mar 15, 2016
0809593
Fix openssl patch
brussee Mar 16, 2016
8483d53
Removed unnecessary method
kived Mar 16, 2016
08b797d
Changed call to env.update
kived Mar 16, 2016
2201007
Changed patch method for optional dependencies
kived Mar 16, 2016
052db55
Changed patch method for optional dependencies
kived Mar 16, 2016
e566a6e
Merge remote-tracking branch 'origin/master'
kived Mar 16, 2016
efd7656
Fixed previous merge mess
kived Mar 16, 2016
318f744
Added config.site to replace autoconf variables from configure command
Mar 17, 2016
e3e0abd
Moved code to the right method for hostpython2 recipe
Mar 17, 2016
fe04e50
Fixes not tested patches
Mar 17, 2016
ec20c90
Fixed missing _sqlite.so module for sdl2 bootstrap
Mar 17, 2016
67f2257
Merge remote-tracking branch 'upstream/master'
Mar 19, 2016
598d5ff
Python 2 updated to version 2.7.11
Mar 19, 2016
b53b3f1
Fixes conflicts with openssl system libs
Mar 20, 2016
03e9162
Fixes compilation errors for pygame recipe and adds freetype support
Mar 20, 2016
53549ba
Fixes the libraries dependencies for pygame bootstraps components
Mar 27, 2016
1335710
Updates the sqlite3's version for pygame's bootstrap
Apr 11, 2016
9964d54
Fixes the build for pygame bootstrap component
Apr 11, 2016
b8e01e7
Solves the runtime link errors and the linkage conflicts at build tim…
Apr 12, 2016
3cb7990
Updates the freetype's version for pygame's bootstrap, and solves iss…
Apr 12, 2016
8bdf47a
Updates the pil's version, adding freetype's support and solves jpeg'…
Apr 12, 2016
636013c
Fixes the load of python's optional libraries for pygame and sdl2 boo…
Apr 12, 2016
9fce3c1
Fixes the build errors for jpeg and png when not uses pygame's boots…
Apr 15, 2016
24bbd7f
Merge branch 'master' of https://github.com/kivy/python-for-android i…
Apr 16, 2016
5ed1e24
Enhances build of sqlite3
Apr 16, 2016
8857f26
Updates jpeg to jpeg-turbo for pygame bootstrap and better build of f…
Apr 16, 2016
a99fde3
Solves issues with pil
Apr 16, 2016
251a749
Solves issues with python2 and config.site file (ignored by github wh…
Apr 17, 2016
99aee09
Updates the sqlite3 recipe and enables fts support
May 13, 2016
98c0ef7
Fixes the merge conflict with upstream
May 13, 2016
760c86e
Fixes the merge conflict with pyjnius
May 13, 2016
347be1a
Solves the compile issues of harfbuzz, freetype and sdl
May 14, 2016
a7c9afa
Fixes the merge conflict with upstream (android, libffi)
Jun 9, 2016
4bcd5d5
Fixes android merge conflict
Jun 9, 2016
1712718
Fixes sh.CommandNotFound on unix platforms for libffi recipe
Jun 9, 2016
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ APP_PROJECT_PATH := $(call my-dir)/..
# sdl_image depends on png and jpeg
# sdl_ttf depends on freetype

APP_MODULES := application sdl sdl_main tremor png jpeg freetype sdl_ttf sdl_image sqlite3
APP_MODULES := application sdl sdl_main tremor png sdl_ttf sdl_image

APP_ABI := $(ARCH)
# AND: I have no idea why I have to specify app_platform when distribute.sh seems to just set the sysroot cflag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@
public class PythonActivity extends Activity implements Runnable {
private static String TAG = "Python";

// The libraries
protected static String[] getLibraries() {
return new String[] {
"sdl",
"sdl_image",
"sdl_ttf",
"sdl_mixer",
"sqlite3",
"ffi",
"python2.7",
"application",
"sdl_main",
};
}


// The audio thread for streaming audio...
private static AudioThread mAudioThread = null;

Expand Down Expand Up @@ -247,30 +263,25 @@ public void run() {
unpackData("private", getFilesDir());
unpackData("public", externalStorage);

System.loadLibrary("sdl");
System.loadLibrary("sdl_image");
System.loadLibrary("sdl_ttf");
System.loadLibrary("sdl_mixer");
System.loadLibrary("python2.7");
System.loadLibrary("application");
System.loadLibrary("sdl_main");
for (String lib : getLibraries()) {
try {
System.loadLibrary(lib);
} catch(UnsatisfiedLinkError e) {
if (lib.startsWith("sqlite3")) {
Log.i("python", "Failed to load lib" + lib + ".so, but that's okay, it's an optional library");
continue;
}
if (lib.startsWith("ffi")) {
Log.i("python", "Failed to load lib" + lib + ".so, but that's okay, it's an optional library");
continue;
}
throw e;
}
}

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

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

try {
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imaging.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingft.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingmath.so");
} catch(UnsatisfiedLinkError e) {
}

if ( mAudioThread == null ) {
Log.i("python", "Starting audio thread");
mAudioThread = new AudioThread(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@

public class PythonService extends Service implements Runnable {

// The libraries
protected static String[] getLibraries() {
return new String[] {
"sdl",
"sdl_image",
"sdl_ttf",
"sdl_mixer",
"sqlite3",
"ffi",
"python2.7",
"application",
"sdl_main",
};
}

// Thread for Python code
private Thread pythonThread = null;

Expand Down Expand Up @@ -78,30 +93,25 @@ public void onDestroy() {
public void run(){

// libraries loading, the same way PythonActivity.run() do
System.loadLibrary("sdl");
System.loadLibrary("sdl_image");
System.loadLibrary("sdl_ttf");
System.loadLibrary("sdl_mixer");
System.loadLibrary("python2.7");
System.loadLibrary("application");
System.loadLibrary("sdl_main");
for (String lib : getLibraries()) {
try {
System.loadLibrary(lib);
} catch(UnsatisfiedLinkError e) {
if (lib.startsWith("sqlite3")) {
Log.i("python", "Failed to load lib" + lib + ".so, but that's okay, it's an optional library");
continue;
}
if (lib.startsWith("ffi")) {
Log.i("python", "Failed to load lib" + lib + ".so, but that's okay, it's an optional library");
continue;
}
throw e;
}
}

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

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

try {
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imaging.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingft.so");
System.load(getFilesDir() + "/lib/python2.7/lib-dynload/_imagingmath.so");
} catch(UnsatisfiedLinkError e) {
}

this.mService = this;
nativeInitJavaEnv();
nativeStart(androidPrivate, androidArgument, pythonHome, pythonPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ protected static String[] getLibraries() {
"SDL2_image",
"SDL2_mixer",
"SDL2_ttf",
"sqlite3",
"ffi",
"python2.7",
"python3.5m",
"main"
Expand All @@ -33,6 +35,14 @@ public static void loadLibraries(File filesDir) {
skippedPython = true;
continue;
}
if (lib.startsWith("sqlite3")) {
Log.v(TAG, "Failed to load lib" + lib + ".so, but that's okay, it's an optional library");
continue;
}
if (lib.startsWith("ffi")) {
Log.v(TAG, "Failed to load lib" + lib + ".so, but that's okay, it's an optional library");
continue;
}
throw e;
}
}
Expand All @@ -43,13 +53,6 @@ public static void loadLibraries(File filesDir) {
} catch(UnsatisfiedLinkError e) {
Log.v(TAG, "Failed to load _io.so or unicodedata.so...but that's okay.");
}

try {
// System.loadLibrary("ctypes");
System.load(filesDirPath + "/lib/python2.7/lib-dynload/_ctypes.so");
} catch(UnsatisfiedLinkError e) {
Log.v(TAG, "Unsatisfied linker when loading ctypes");
}

Log.v(TAG, "Loaded everything!");
}
Expand Down
7 changes: 6 additions & 1 deletion pythonforandroid/recipes/android/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ class AndroidRecipe(IncludedFilesBehaviour, CythonRecipe):
# name = 'android'
version = None
url = None

src_filename = 'src'

depends = [('pygame', 'sdl2', 'webviewjni'), ('python2', 'python3')]

config_env = {}

call_hostpython_via_targetpython = False

def get_recipe_env(self, arch):
env = super(AndroidRecipe, self).get_recipe_env(arch)
env.update(self.config_env)
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7'
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
' -lpython2.7'
return env

def prebuild_arch(self, arch):
Expand Down
71 changes: 55 additions & 16 deletions pythonforandroid/recipes/freetype/__init__.py
179B
Original file line number Diff line number Diff line change
@@ -1,39 +1,78 @@

from pythonforandroid.toolchain import Recipe, shprint, current_directory, ArchARM
from pythonforandroid.toolchain import Recipe
from pythonforandroid.logger import shprint, info
from pythonforandroid.util import current_directory, ensure_dir
from os.path import exists, join, realpath
from os import uname
import glob
import sh

# NOTE: The libraries, freetype and harfbuzz, are special because they has cyclic dependencies:
# freetype can be build with harfbuzz support and harfbuzz can be build with freetype support.
# So, to correctly build both libraries, first we must build freetype without harfbuzz,
# then we build harfbuzz with freetype support and then we build again the freetype
# library with harfbuzz support. See reference at:
# https://sourceforge.net/projects/freetype/files/freetype2/2.5.3/
class FreetypeRecipe(Recipe):

version = '2.5.5'
url = 'http://download.savannah.gnu.org/releases/freetype/freetype-{version}.tar.gz'

depends = ['harfbuzz']
opt_depends = ['harfbuzz']

def should_build(self, arch):
if exists(join(self.get_build_dir(arch.arch), 'objs', '.libs', 'libfreetyp F438 e.so')):
if exists(join(self.get_build_dir(arch.arch), 'objs', '.libs', 'libfreetype.a')):
return False
return True

def build_arch(self, arch):
def get_jni_dir(self, arch):
return join(self.ctx.bootstrap.build_dir, 'jni')

def get_lib_dir(self, arch):
return join(self.get_build_dir(arch.arch), 'objs', '.libs')

def build_arch(self, arch, with_harfbuzz=False):
env = self.get_recipe_env(arch)
use_harfbuzz = False
prefix_path = realpath('.')
if 'harfbuzz' in self.ctx.recipe_build_order:
use_harfbuzz = True
if not with_harfbuzz:
info('\t - This is the first Build of freetype (without harfbuzz)')
prefix_path = join(self.get_build_dir(arch.arch), 'install')

if with_harfbuzz:
# Is the second build, now we link with harfbuzz
info('\t - This is the second Build of freetype: enabling harfbuzz support ...')
harfbuzz_build = Recipe.get_recipe('harfbuzz', self.ctx).get_build_dir(arch.arch)
freetype_install = join(self.get_build_dir(arch.arch), 'install')
env['CFLAGS'] = ' '.join(
[env['CFLAGS'], '-I{harfbuzz}'.format(harfbuzz=harfbuzz_build),
'-I{harfbuzz}/src'.format(harfbuzz=harfbuzz_build),
'-I{freetype}/include/freetype2'.format(freetype=freetype_install),
'-L{freetype}/lib -lfreetype'.format(freetype=freetype_install)])
env['LDFLAGS'] = ' '.join(['-L{freetype}/lib -lfreetype'.format(freetype=freetype_install)])

harfbuzz_recipe = Recipe.get_recipe('harfbuzz', self.ctx)
env['LDFLAGS'] = ' '.join(
[env['LDFLAGS'],
'-L{}'.format(join(harfbuzz_recipe.get_build_dir(arch.arch), 'src', '.libs'))])
env['HARFBUZZ_CFLAGS'] = '-I{harfbuzz} -I{harfbuzz}/src'.format(harfbuzz=harfbuzz_build)
env['HARFBUZZ_LIBS'] = '-L{freetype}/lib -lfreetype ' \
'-L{harfbuzz}/src/.libs -lharfbuzz'.format(
freetype=freetype_install, harfbuzz=harfbuzz_build)

# Build freetype library
with current_directory(self.get_build_dir(arch.arch)):
configure = sh.Command('./configure')
shprint(configure, '--host=arm-linux-androideabi',
'--prefix={}'.format(realpath('.')),
'--without-zlib', '--with-png=no', '--enable-shared',
_env=env)
'--prefix={}'.format(prefix_path),
'--without-zlib', '--with-png=no',
'--disable-shared', _env=env)
shprint(sh.make, '-j5', _env=env)

shprint(sh.cp, 'objs/.libs/libfreetype.so', self.ctx.libs_dir)
if not with_harfbuzz and use_harfbuzz:
# Is first build, install the compiled lib, and clean build env
shprint(sh.make, 'install', _env=env)
shprint(sh.make, 'distclean', _env=env)
else:
# This is the second build (or the first if harfbuzz not enabled),
# now we copy definitive libs to libs collection. Be sure to link
# your recipes to the definitive library, located at: objs/.libs
ensure_dir(join(self.ctx.libs_dir, arch.arch))
shprint(sh.cp, 'objs/.libs/libfreetype.a', self.ctx.libs_dir)


recipe = FreetypeRecipe()
52 changes: 41 additions & 11 deletions pythonforandroid/recipes/harfbuzz/__init__.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,63 @@

from pythonforandroid.toolchain import Recipe, shprint, current_directory, ArchARM
from os.path import exists, join, realpath
from os import uname
import glob
from pythonforandroid.toolchain import Recipe, shprint
from pythonforandroid.util import current_directory, ensure_dir
from os.path import exists, join
import sh


# NOTE: The libraries, freetype and harfbuzz, are special because they has cyclic dependencies:
# freetype can be build with harfbuzz support and harfbuzz can be build with freetype support.
# So, to correctly build both libraries, first we must build freetype without harfbuzz,
# then we build harfbuzz with freetype support and then we build again the freetype
# library with harfbuzz support. See reference at:
# https://sourceforge.net/projects/freetype/files/freetype2/2.5.3/
class HarfbuzzRecipe(Recipe):
version = '0.9.40'
url = 'http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-{version}.tar.bz2'

def should_build(self, arch):
if exists(join(self.get_build_dir(arch.arch), 'src', '.libs', 'libharfbuzz.so')):
if exists(join(self.get_build_dir(arch.arch),
'src', '.libs', 'libharfbuzz.a')):
return False
return True

def get_jni_dir(self, arch):
return join(self.ctx.bootstrap.build_dir, 'jni')

def get_lib_dir(self, arch):
if 'pygame' in self.ctx.recipe_build_order:
return join(self.get_jni_dir(arch), 'harfbuzz', arch.arch)
return join(self.get_build_dir(arch.arch), 'src', '.libs')

def build_arch(self, arch):

env = self.get_recipe_env(arch)
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(
self.ctx.get_libs_dir(arch.arch) +
'-L{}'.format(self.ctx.libs_dir))
env['LDFLAGS'] += ' -L{} -L{}'.format(self.ctx.get_libs_dir(arch.arch), self.ctx.libs_dir)

with_freetype = 'no'
# FREETYPE FLAGS
if 'freetype' in self.ctx.recipe_build_order:
with_freetype = 'yes'
freetype = self.get_recipe('freetype', self.ctx)
freetype_install = join(freetype.get_build_dir(arch.arch), 'install')
env['CFLAGS'] = ' '.join([env['CFLAGS'], '-I{}/include/freetype2'.format(freetype_install),
'-L{}/lib'.format(freetype_install), '-lfreetype'])
# HARFBUZZ FLAGS
env['CFLAGS'] = ' '.join([env['CFLAGS'], '-I{}'.format(self.get_build_dir(arch.arch)),
'-I{}/src'.format(self.get_build_dir(arch.arch))])
env['LDFLAGS'] += ' -L{}/src/.libs'.format(self.get_build_dir(arch.arch))

with current_directory(self.get_build_dir(arch.arch)):
configure = sh.Command('./configure')
shprint(configure, '--without-icu', '--host=arm-linux=androideabi',
'--prefix={}'.format(join(self.ctx.build_dir, 'python-install')),
'--without-freetype', '--without-glib', _env=env)
'--with-freetype={}'.format(with_freetype), '--without-glib',
'--disable-shared', _env=env)
shprint(sh.make, '-j5', _env=env)

shprint(sh.cp, '-L', join('src', '.libs', 'libharfbuzz.so'), self.ctx.libs_dir)
shprint(sh.cp, '-L', join('src', '.libs', 'libharfbuzz.a'), self.ctx.libs_dir)

if 'freetype' in self.ctx.recipe_build_order:
# Rebuild freetype with harfbuzz support
freetype.build_arch(arch, with_harfbuzz=True)

recipe = HarfbuzzRecipe()
Loading
0