Get a local copy of the source code using the following command:
$ hg clone https://code.google.com/p/python-for-android/
Just focus on the python-build subdirectory and make sure the python-build/python-src subdirectory is not present (remove it if it came with the Mercurial repository, or else the compilation will fail).
Set up your environment so that the python-for-android build script can pick up the ndk-build script from the Android NDK:
$ export ANDROID_NDK_ROOT=/home/<your-directory>/android-ndk-r8
$ export PATH=$ANDROID_NDK_ROOT:$PATH
Finally build Python for Android by issuing the following command:
$ cd python-for-android/python-build
$ rm -rf python-src$ bash build.sh
Note that on my Ubuntu 12.04 machine I had initially the following compilation error:
Traceback (most recent call last):
File "build.py", line 161, in <module>
os.path.join(pwd, 'output.temp', 'usr'))
File "build.py", line 89, in zipup
zip_file = zipfile.ZipFile(out_path, 'w', compression=zipfile.ZIP_DEFLATED)
File "/home/danilo/python-for-android/python-build/host/lib/python2.6/zipfile.py", line 660, in __init__
"Compression requires the (missing) zlib module"
RuntimeError: Compression requires the (missing) zlib module
I identified the problem in having the zlib library in my system installed under /lib/x86_64-linux-gnu/ instead of one of the traditional lib directories covered by the Python setup.py script. Also on my system I only had libz.so.1 and not libz.so. So to fix both problems I just created a symlink in the standard /usr/lib directory as follows:
$ cd /usr/lib
$ sudo ln -s /lib/x86_64-linux-gnu/libz.so.1 libz.soWith this fix the build.sh script was able to successfully build the zlib module for the host environment and create the following zipped files:
- python_extras_r14.zip
- python-lib_r16.zip
- python_r16.zip
- python_scripts_r13.zip
Of these I only used the python_r16.zip which contains the stripped python interpreter and the runtime libraries, and the python-lib_r16.zip which contains the include header files such as Python.h that can be used to compile Python bindings at development time.
0 comments:
Post a Comment