|
BuildingPython
How to build Python for Android.
Featured IntroductionHow to build Python for Android. DetailsFor linux Download and install Android NDK. Grab the latest Py4A Source. The build script needs to be able to find both ndk-build and arm-eabi-strip. Here is an example of how to set your path: export ANDROID_NDK=~/android-ndk-r5 export PATH=$PATH:$ANDROID_NDK:$ANDROID_NDK/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86 Then, to actually build python: bash build.sh See: BuildingModules for how to build modules. |
► Sign in to add a comment
29/7/11 the build.sh system is broken. it fails after compilaton
I was using android-ndk-r6b. To complete build, I have to
1. in build.sh +mv ${PYTHONSRC} temp if [ ! -d ${PYTHONSRC} ]; then ... fi +cp temp/* ${PYTHONSRC}/ -rf 2. in build.py def strip(path): - run('arm-eabi-strip %s' % path) + run('arm-linux-androideabi-strip %s' % path)for ndk r6b you need comment 1 above, comment 2 has been applied to source already. as well, the PATH needs to be:
Hi Robbie and all, I have built the Py4A for x86 successfully, please refer to the following steps:
0. Enter the python-build folder, then modify setup.cfg : set linux-x86
1.1 Modify the build.sh - Backup the python-src to temp, then restore it if ! -d temp ; then
fi rm -rf ${PYTHONSRC} if ! -d ${PYTHONSRC} ; then fi cp temp/ ${PYTHONSRC} -rf1.2 Create the App_x86.mk as below: APP_ABI := x86
1.3 Mdify the ndk-build in build.sh file ndk-build NDK_APPLICATION_MK=${CWD}/App_x86.mk
1.4 Specify the x86 output folders in build.sh file mv obj/local/x86/python ${OUT}/usr/bin mv obj/local/x86/lib.so ${OUT}/usr/lib mv obj/local/x86/.so ${OUT}/usr/lib/python2.6/lib-dynload
2. Modify build.sy - specify the i686 strip def strip(path):
3. Modify libffi/Android.mk - replace all arm with x86
#if CONF_HAVE_LONG_DOUBLE // android changed #define FFI_TYPE_LONGDOUBLE 4 #else #define FFI_TYPE_LONGDOUBLE 4 //FFI_TYPE_DOUBLE //Zou Jinde #endif4. Modify openssl/crypto/Android.mk:
5. Modify openssl/ssl/Android.mk
6. Modify python/jni/modules.mk, remark the following lines #$(call import-module, openssl) #LOCAL_PATH := $(PYTHON_SRC_PATH) #LOCAL_C_INCLUDES += $(PYTHON_SRC_PATH) $(PYTHON_SRC_PATH)/Include $(OPENSSL)/include $(OPENSSL) #LOCAL_MODULE := ssl #LOCAL_MODULE_FILENAME := ssl #LOCAL_SRC_FILES := Modules/ssl.c #LOCAL_SHARED_LIBRARIES := libpython2.6 libcrypto libssl #include $(BUILD_SHARED_LIBRARY)