Skip to content

Commit a38252e

Browse files
committed
Merge git://github.com/kivy/python-for-android
2 parents 7e7b924 + 6e65534 commit a38252e

7 files changed

Lines changed: 155 additions & 11 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ src/default.properties
88
dist
99
*.pyc
1010
testsuite
11+
12+
#ECLIPSE + PYDEV
13+
.project
14+
.pydevproject

README.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,26 @@ Global overview
1414
---------------
1515

1616
#. Download Android NDK, SDK
17-
#. Launch "android", and download latest Android platform
17+
18+
* NDK: http://dl.google.com/android/ndk/android-ndk-r8c-linux-x86.tar.bz2
19+
20+
* More details at: http://developer.android.com/tools/sdk/ndk/index.html
21+
22+
* SDK: http://dl.google.com/android/android-sdk_r21.0.1-linux.tgz
23+
24+
* More details at:http://developer.android.com/sdk/index.html
25+
26+
#. Launch "android", and download latest Android platform, here API 14, which would be Android 4.0
27+
1828
#. Export some environment variables::
1929

2030
export ANDROIDSDK="/path/to/android/android-sdk-linux_86"
21-
export ANDROIDNDK="/path/to/android/android-ndk-r7"
22-
export ANDROIDNDKVER=r7
31+
export ANDROIDNDK="/path/to/android/android-ndk-r8c"
32+
export ANDROIDNDKVER=r8c
2333
export ANDROIDAPI=14
2434

35+
(Of course correct the paths mentioned in ANDROIDSDK and ANDROIDNDK)
36+
2537
#. Clone python-for-android::
2638

2739
git clone git://github.com/kivy/python-for-android

cythonizer.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import os, sys
2+
3+
class cythonizer():
4+
def __init__(self,
5+
android_ndk = os.environ["ANDROIDNDK"],
6+
android_api = os.environ["ANDROIDAPI"],
7+
python_for_android = os.path.join(os.path.split(os.path.realpath(__file__))[0])
8+
):
9+
self.android_ndk = android_ndk
10+
self.android_api = android_api
11+
self.py_for_a = python_for_android
12+
13+
for path in [self.android_ndk, self.py_for_a]:
14+
if not os.path.isdir(path):
15+
print "!! Haven't found path:", repr(path)
16+
sys.exit()
17+
18+
self.gcc = "%s/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc" %(self.android_ndk)
19+
self.sysroot = "%s/platforms/android-%s/arch-arm" %(self.android_ndk, self.android_api)
20+
self.a_incl = "-I%s/platforms/android-%s/arch-arm/usr/include" %(self.android_ndk, self.android_api)
21+
self.p_incl = "-I%s/build/python-install/include/python2.7" %(self.py_for_a)
22+
self.libs = "-L%s/build/libs" %(self.py_for_a)
23+
self.p_libs = "-L%s/build/python-install/lib" %(self.py_for_a)
24+
self.a_libs = "-L%s/platforms/android-%s/arch-arm/usr/lib" %(self.android_ndk, self.android_api)
25+
26+
def make_o(self, c_file, o_file):
27+
command = """%s -mandroid -fomit-frame-pointer -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC --sysroot %s %s %s -c database.c -o database.o""" %(self.gcc,
28+
self.sysroot,
29+
self.a_incl,
30+
self.p_incl)
31+
print command
32+
33+
def make_so(self, o_file, so_file= None):
34+
if so_file == None:
35+
so_file = os.path.splitext(os.path.realpath(o_file))[0]+".so"
36+
command = """%s -shared -O3 -mandroid -fomit-frame-pointer --sysroot %s -lm -lGLESv2 -lpython2.7 %s %s %s %s -o %s """ %(self.gcc,
37+
self.sysroot,
38+
self.libs,
39+
self.p_libs,
40+
self.a_libs,
41+
o_file,
42+
so_file)
43+
print command
44+
def make(self, py_pyx):
45+
for root, dirs, files in os.walk(directory):
46+
for file in files:
47+
if file.endswith('.py') or file.endswith('.pyx'):
48+
print file
49+
self.make_o(py_pyx)
50+
self.make_so(py_pyx)
51+
52+
if __name__ == "__main__":
53+
c = cythonizer()
54+
c.make("test.py")

distribute.sh

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,36 @@ function usage() {
223223
exit 0
224224
}
225225

226+
# Check installation state of a debian package list.
227+
# Return all missing packages.
228+
function check_pkg_deb_installed() {
229+
PKGS=$1
230+
MISSING_PKGS=""
231+
for PKG in $PKGS; do
232+
CHECK=$(dpkg -s $PKG 2>&1)
233+
if [ $? -eq 1 ]; then
234+
MISSING_PKGS="$PKG $MISSING_PKGS"
235+
fi
236+
done
237+
if [ "X$MISSING_PKGS" != "X" ]; then
238+
error "Packages missing: $MISSING_PKGS"
239+
error "It might break the compilation, except if you installed thoses packages manually."
240+
fi
241+
}
242+
243+
function check_build_deps() {
244+
DIST=$(lsb_release -is)
245+
info "Check build dependencies for $DIST"
246+
case $DIST in
247+
Debian|Ubuntu)
248+
check_pkg_deb_installed "build-essential zlib1g-dev cython"
249+
;;
250+
*)
251+
debug "Avoid check build dependencies, unknow platform $DIST"
252+
;;
253+
esac
254+
}
255+
226256
function run_prepare() {
227257
info "Check enviromnent"
228258
if [ "X$ANDROIDSDK" == "X" ]; then
@@ -548,7 +578,7 @@ function run_distribute() {
548578
try cp -a $BUILD_PATH/libs/* libs/$ARCH/
549579

550580
debug "Copy java files from various libs"
551-
try cp -a $BUILD_PATH/java/* src
581+
cp -a $BUILD_PATH/java/* src
552582

553583
debug "Fill private directory"
554584
try cp -a python-install/lib private/
@@ -593,6 +623,7 @@ function run_biglink() {
593623
}
594624

595625
function run() {
626+
check_build_deps
596627
run_prepare
597628
run_source_modules
598629
run_get_packages
@@ -653,9 +684,9 @@ while getopts ":hvlfxm:d:s" opt; do
653684
f)
654685
DO_CLEAN_BUILD=1
655686
;;
656-
x)
657-
DO_SET_X=1
658-
;;
687+
x)
688+
DO_SET_X=1
689+
;;
659690
\?)
660691
echo "Invalid option: -$OPTARG" >&2
661692
exit 1

recipes/kivy_stable/recipe.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
VERSION_kivy_stable=1.5.1
4+
URL_kivy_stable=https://github.com/kivy/kivy/archive/$VERSION_kivy_stable.zip
5+
DEPS_kivy_stable=(pygame pyjnius android)
6+
MD5_kivy_stable=
7+
BUILD_kivy_stable=$BUILD_PATH/kivy_stable/$VERSION_kivy_stable
8+
RECIPE_kivy_stable=$RECIPES_PATH/kivy_stable
9+
10+
function prebuild_kivy_stable() {
11+
true
12+
}
13+
14+
function build_kivy_stable() {
15+
if [ -d "$BUILD_PATH/python-install/lib/python2.7/site-packages/kivy" ]; then
16+
#return
17+
true
18+
fi
19+
20+
cd $BUILD_kivy_stable
21+
22+
push_arm
23+
24+
export LDFLAGS="$LDFLAGS -L$LIBS_PATH"
25+
export LDSHARED="$LIBLINK"
26+
27+
# fake try to be able to cythonize generated files
28+
$BUILD_PATH/python-install/bin/python.host setup.py build_ext
29+
try find . -iname '*.pyx' -exec cython {} \;
30+
try $BUILD_PATH/python-install/bin/python.host setup.py build_ext -v
31+
try find build/lib.* -name "*.o" -exec $STRIP {} \;
32+
try $BUILD_PATH/python-install/bin/python.host setup.py install -O2
33+
34+
try rm -rf $BUILD_PATH/python-install/lib/python*/site-packages/kivy/tools
35+
36+
unset LDSHARED
37+
pop_arm
38+
}
39+
40+
function postbuild_kivy_stable() {
41+
true
42+
}
43+

recipes/mysql_connector/recipe.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

3-
VERSION_mysql_connector=1.0.7
4-
URL_mysql_connector=https://launchpad.net/debian/+archive/primary/+files/mysql-connector-python_$VERSION_mysql_connector.orig.tar.gz
3+
VERSION_mysql_connector=1.0.8
4+
URL_mysql_connector=http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-$VERSION_mysql_connector.tar.gz
55
DEPS_mysql_connector=()
6-
MD5_mysql_connector=44c6b2c314c7ab7b7060484970b5ff23
6+
MD5_mysql_connector=1f2dd335c72684d51ee5d34f127d7ca9
77
BUILD_mysql_connector=$BUILD_PATH/mysql_connector/$(get_directory $URL_mysql_connector)
88
RECIPE_mysql_connector=$RECIPES_PATH/mysql_connector
99

src/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python2
1+
#!/usr/bin/env python2.7
22

33
from os.path import dirname, join, isfile, realpath, relpath, split
44
from zipfile import ZipFile

0 commit comments

Comments
 (0)