python build for kolibri-android-wrapper
To generete the python build python_27.zip
and python_extras_27.zip
, run the following commands:
sudo docker build -t androidpython .
container_id=`sudo docker create androidpython`
sudo docker cp $container_id:/python-android27/python_27.zip .
sudo docker cp $container_id:/python-android27/python_extras_27.zip .
To generate non-PIE python build, please reference the upstream flag settings.
- how to bring up interactive python via adb:
cd <path_to_your_sdk>/platform-tools
./adb shell
run-as com.android.kolibri27
export PYTHONHOME=/data/data/com.android.kolibri27/files/python
export PYTHONPATH=/sdcard/com.android.kolibri27/extras/python:/data/data/com.android.kolibri27/files/python/lib/python2.7/lib-dynload:/data/data/com.android.kolibri27/files/python/lib/python2.7
export PATH=$PYTHONHOME/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/data/com.android.kolibri27/files/python/lib:/data/data/com.android.kolibri27/files/python/lib/python2.7/lib-dynload
python
- To check if a file is PIE enabled in Ubuntu:
sudo apt-get install hardening-includes
hardening-check <file path>
- Able to generate a minimum PIE enabled python_27.zip, meaning when install on android, we can bring up the interactive python via adb, but lack some python libs to start Kolibri.
- Not able to generate python_extras_27.zip yet, still working on it.
Current status(We need to get the status as close as possible to the upstream status):
Python build finished, but the necessary bits to build these modules were not found:
_bsddb _curses _curses_panel
_tkinter bsddb185 bz2
dbm dl gdbm
imageop linuxaudiodev nis
ossaudiodev readline sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
Failed to build these modules:
_bisect _codecs_cn _codecs_hk
_codecs_iso2022 _codecs_jp _codecs_kr
_codecs_tw _collections _csv
_ctypes _ctypes_test _elementtree
_functools _hashlib _heapq
_hotshot _io _json
_locale _lsprof _multibytecodec
_multiprocessing _random _sha256
_sha512 _socket _sqlite3
_ssl _struct _testcapi
array audioop binascii
cmath cPickle crypt
cStringIO datetime fcntl
future_builtins grp itertools
math mmap operator
parser pyexpat resource
select spwd strop
syslog termios time
unicodedata zlib
Upstream status(the current progress of the upstream):
Python build finished, but the necessary bits to build these modules were not found:
_bsddb _curses _curses_panel
_tkinter bsddb185 bz2
dbm dl gdbm
imageop linuxaudiodev nis
ossaudiodev readline sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
Failed to build these modules:
_ctypes_test _locale audioop
grp spwd
Reference: http://code.google.com/p/python-for-android/
./bootstrap.sh
Downloads Python-2.7.2 source
patches Python for android
builds hostpython and hostpgen
./build.sh
builds python library for android
./package.sh
creates python_rxx.zip and python_extras_rxx.zip
./pip_install.sh
install python packages using pip.
example:
./pip_install.sh python-twitter
-
I installed the following packages:
sudo apt-get install build-essential bison flex autoconf automake autotools-dev quilt libcurl3 curl openssh-server ant mercurial filezilla pure-ftpd dpatch texinfo libncurses5-dev libgmp3-dev libmpfr-dev gawk patchutils binutils-dev zlib1g-dev
and
sudo apt-get install git-core gnupg gperf libc6-dev x11proto-core-dev libx11-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc libreadline-dev libreadline6 ia32-libs-multiarch libzip-dev libzip-dev libzzip-dev libzzip-0-13
-
I'm using ubuntu ubuntu-14.04.5-desktop-amd64.iso (64-bit)
-
With gcc-4.8
-
the
site.py
file insidepython_extras_27.zip
won't work, a work around for now is to replace it with thesite.py
fromandroid-python27
project. -
Under
android-ndk-r13b/toolchains/
need to rename everything tosomething-4.4.3
-
Under
android-ndk-r13b/toolchains/x86_64-4.4.3/prebuilt/linux-x86_64/bin/
need to renamex86_64-linux-android-gcc
tox86_64-gcc
;x86_64-linux-android-g++
tox86_64-g++
;x86_64-linux-android-strip
tox86_64-strip
-
Under
android-ndk-r13b/toolchains/aarch64-linux-android-4.4.3/prebuilt/linux-x86_64/bin/
need to renameaarch64-linux-android-g++
toaarch64-g++
;aarch64-linux-android-gcc
toaarch64-gcc
;aarch64-linux-android-strip
toaarch64-strip
-
Make
openssl/AndroidManifest.xml
minSdkVersion=24 -
In order to compile openssl successfully and generate
libcrypt.so
,libcrypto.so
,libsqlite3.so
,libssl.so
that are required to run python on android, we need to modifyandroid-ndk-r13b/build/core/default-build-commands/mk
, find around line 113 and change toTARGET_LDLIBS:= -lz -lc -lm
. After we got thoese share libraries, restore the change toTARGET_LDLIBS:= -lc -lm
, and continue to build the python. It's a bit tricky to get both python and these shared libraries built at one shoot. Sometimes you may want to prepare two envirenment to build them separately.