Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ src/default.properties
dist
*.pyc
testsuite

#ECLIPSE + PYDEV

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also added two files to .gitignore which are created when using Eclipse+PyDev

.project
.pydevproject
18 changes: 15 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,26 @@ Global overview
---------------

#. Download Android NDK, SDK
#. Launch "android", and download latest Android platform

* NDK: http://dl.google.com/android/ndk/android-ndk-r8c-linux-x86.tar.bz2

* More details at: http://developer.android.com/tools/sdk/ndk/index.html

* SDK: http://dl.google.com/android/android-sdk_r21.0.1-linux.tgz

* More details at:http://developer.android.com/sdk/index.html

#. Launch "android", and download latest Android platform, here API 14, which would be Android 4.0

#. Export some environment variables::

export ANDROIDSDK="/path/to/android/android-sdk-linux_86"
export ANDROIDNDK="/path/to/android/android-ndk-r7"
export ANDROIDNDKVER=r7
export ANDROIDNDK="/path/to/android/android-ndk-r8c"
export ANDROIDNDKVER=r8c
export ANDROIDAPI=14

(Of course correct the paths mentioned in ANDROIDSDK and ANDROIDNDK)

#. Clone python-for-android::

git clone git://github.com/kivy/python-for-android
Expand Down
54 changes: 54 additions & 0 deletions cythonizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import os, sys

class cythonizer():
def __init__(self,
android_ndk = os.environ["ANDROIDNDK"],
android_api = os.environ["ANDROIDAPI"],
python_for_android = os.path.join(os.path.split(os.path.realpath(__file__))[0])
):
self.android_ndk = android_ndk
self.android_api = android_api
self.py_for_a = python_for_android

for path in [self.android_ndk, self.py_for_a]:
if not os.path.isdir(path):
print "!! Haven't found path:", repr(path)
sys.exit()

self.gcc = "%s/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc" %(self.android_ndk)
self.sysroot = "%s/platforms/android-%s/arch-arm" %(self.android_ndk, self.android_api)
self.a_incl = "-I%s/platforms/android-%s/arch-arm/usr/include" %(self.android_ndk, self.android_api)
self.p_incl = "-I%s/build/python-install/include/python2.7" %(self.py_for_a)
self.libs = "-L%s/build/libs" %(self.py_for_a)
self.p_libs = "-L%s/build/python-install/lib" %(self.py_for_a)
self.a_libs = "-L%s/platforms/android-%s/arch-arm/usr/lib" %(self.android_ndk, self.android_api)

def make_o(self, c_file, o_file):
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,
self.sysroot,
self.a_incl,
self.p_incl)
print command

def make_so(self, o_file, so_file= None):
if so_file == None:
so_file = os.path.splitext(os.path.realpath(o_file))[0]+".so"
command = """%s -shared -O3 -mandroid -fomit-frame-pointer --sysroot %s -lm -lGLESv2 -lpython2.7 %s %s %s %s -o %s """ %(self.gcc,
self.sysroot,
self.libs,
self.p_libs,
self.a_libs,
o_file,
so_file)
print command
def make(self, py_pyx):
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith('.py') or file.endswith('.pyx'):
print file
self.make_o(py_pyx)
self.make_so(py_pyx)

if __name__ == "__main__":
c = cythonizer()
c.make("test.py")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Started to make a simple script to make a .so of a .py or .pyx.
Most of all a OptParser is need..

43 changes: 43 additions & 0 deletions recipes/kivy_stable/recipe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

VERSION_kivy_stable=1.5.1
URL_kivy_stable=https://github.com/kivy/kivy/archive/$VERSION_kivy_stable.zip
DEPS_kivy_stable=(pygame pyjnius android)
MD5_kivy_stable=
BUILD_kivy_stable=$BUILD_PATH/kivy_stable/$VERSION_kivy_stable
RECIPE_kivy_stable=$RECIPES_PATH/kivy_stable

function prebuild_kivy_stable() {
true
}

function build_kivy_stable() {
if [ -d "$BUILD_PATH/python-install/lib/python2.7/site-packages/kivy" ]; then
#return
true
fi

cd $BUILD_kivy_stable

push_arm

export LDFLAGS="$LDFLAGS -L$LIBS_PATH"
export LDSHARED="$LIBLINK"

# fake try to be able to cythonize generated files
$BUILD_PATH/python-install/bin/python.host setup.py build_ext
try find . -iname '*.pyx' -exec cython {} \;
try $BUILD_PATH/python-install/bin/python.host setup.py build_ext -v
try find build/lib.* -name "*.o" -exec $STRIP {} \;
try $BUILD_PATH/python-install/bin/python.host setup.py install -O2

try rm -rf $BUILD_PATH/python-install/lib/python*/site-packages/kivy/tools

unset LDSHARED
pop_arm
}

function postbuild_kivy_stable() {
true
}

6 changes: 3 additions & 3 deletions recipes/mysql_connector/recipe.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

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

Expand Down