Skip to content

Python 2.7.11 #775

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 3 commits into from
Closed
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
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 jpeg freetype 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
26 changes: 15 additions & 11 deletions pythonforandroid/recipes/hostpython2/Setup
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ PYTHONPATH=$(COREPYTHONPATH)
# various reasons; therefore they are listed here instead of in the
# normal order.

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

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

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

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

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

# Standard I/O baseline
#_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


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

fcntl fcntlmodule.c # fcntl(2) and ioctl(2)
#spwd spwdmodule.c # spwd(3)
#spwd spwdmodule.c # spwd(3)
#grp grpmodule.c # grp(3)
select selectmodule.c # select(2); not on ancient System V

Expand Down Expand Up @@ -299,7 +303,7 @@ _sha512 sha512module.c
#sunaudiodev sunaudiodev.c


# A Linux specific module -- off by default; this may also work on
# A Linux specific module -- off by default; this may also work on
# some *BSDs.

#linuxaudiodev linuxaudiodev.c
Expand Down Expand Up @@ -365,7 +369,7 @@ _sha512 sha512module.c

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


# Generic (SunOS / SVR4) dynamic loading module.
Expand Down
24 changes: 17 additions & 7 deletions pythonforandroid/recipes/hostpython2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

from pythonforandroid.toolchain import Recipe, shprint, current_directory, info, warning
from os.path import join, exists
from os import chdir
from os import environ
import sh


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

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

def should_build(self, arch):
if exists(join(self.get_build_dir(), 'hostpython')):
info('Setting ctx hostpython2 from previous build...')
self.ctx.hostpython = join(self.get_build_dir(), 'hostpython')
self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen')
return False
else:
info('Must build hostpython2...')
return True

def prebuild_arch(self, arch):
# Override hostpython Setup?
shprint(sh.cp, join(self.get_recipe_dir(), 'Setup'),
join(self.get_build_dir(), 'Modules', 'Setup'))

def build_arch(self, arch):
env = dict(environ)
with current_directory(self.get_build_dir()):

if exists('hostpython'):
info('hostpython already exists, skipping build')
self.ctx.hostpython = join(self.get_build_dir(),
'hostpython')
self.ctx.hostpgen = join(self.get_build_dir(),
'hostpgen')
return

configure = sh.Command('./configure')

shprint(configure)
shprint(sh.make, '-j5')
shprint(configure, _env=env)
shprint(sh.make, '-j5', _env=env)

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

Expand Down
10 changes: 6 additions & 4 deletions pythonforandroid/recipes/pygame_bootstrap_components/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pythonforandroid.toolchain import BootstrapNDKRecipe, current_directory, shprint, info
from os.path import exists, join
from pythonforandroid.toolchain import BootstrapNDKRecipe, current_directory
from pythonforandroid.logger import shprint, info
from os.path import exists, join, basename
import sh
import glob

Expand All @@ -19,9 +20,10 @@ def prebuild_arch(self, arch):
return
for dirn in glob.glob(join(self.get_build_dir(arch),
'pygame_bootstrap_jni', '*')):
shprint(sh.mv, dirn, './')
if basename(dirn) not in ['sqlite3']:
shprint(sh.mv, dirn, './')
info('Unpacking was successful, deleting original container dir')
shprint(sh.rm, '-rf', self.get_build_dir(arch))


recipe = PygameJNIComponentsRecipe()
Loading