[PyQt] [pyqtdeploy] Qt Android Extras

Sébastien RAMAGE sramage at poifindus.com
Mon Aug 10 13:41:12 BST 2015

The following is based on kivy/python-for-android
So currently on Android pyjnius needs sdl so we need to compile sdl first

sdl source can be found here

this is what python-for-android do for sdl :

push_arm <== initialize environment , define in distribute.sh
try ndk-build V=1 <== build
pop_arm <== leave environment
try cp -a $SRC_PATH/libs/$ARCH/*.so $LIBS_PATH

next for pyjnius :

push_arm <== initialize environment , define in distribute.sh

     export LDSHARED="$LIBLINK"

     # fake try to be able to cythonize generated files
     $HOSTPYTHON setup.py build_ext   <=$HOSTPYTHON seems to be a local 
python binary compiled just before
     try find . -iname '*.pyx' -exec $CYTHON {} \;  <= $CYTHON is a 
system wide installed cython
     try $HOSTPYTHON setup.py build_ext -v
     try find build/lib.* -name "*.o" -exec $STRIP {} \;
     try $HOSTPYTHON setup.py install -O2
     try cp -a jnius/src/org $JAVACLASS_PATH

     unset LDSHARED

detail of push_arm :

function push_arm() {
     info "Entering in ARM environment"

     # save for pop
     export OLD_PATH=$PATH
     export OLD_CFLAGS=$CFLAGS
     export OLD_CC=$CC
     export OLD_CXX=$CXX
     export OLD_AR=$AR
     export OLD_RANLIB=$RANLIB
     export OLD_STRIP=$STRIP
     export OLD_MAKE=$MAKE
     export OLD_LD=$LD

     # to override the default optimization, set OFLAG
     #export OFLAG="-Os"
     #export OFLAG="-O2"

     export CFLAGS="-DANDROID -mandroid $OFLAG -fomit-frame-pointer 
--sysroot $NDKPLATFORM"
     if [ "X$ARCH" == "Xarmeabi-v7a" ]; then
         CFLAGS+=" -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb"
     export CXXFLAGS="$CFLAGS"

     # that could be done only for darwin platform, but it doesn't hurt.
     export LDFLAGS="-lm"

     # this must be something depending of the API level of Android
     PYPLATFORM=$($PYTHON -c 'from __future__ import print_function; 
import sys; print(sys.platform)')
     if [ "$PYPLATFORM" == "linux2" ]; then
     elif [ "$PYPLATFORM" == "linux3" ]; then

     if [ "X$ANDROIDNDKVER" == "Xr5b" ]; then
         export TOOLCHAIN_PREFIX=arm-eabi
         export TOOLCHAIN_VERSION=4.4.0
     elif [ "X${ANDROIDNDKVER:0:2}" == "Xr7" ] || [ 
"X${ANDROIDNDKVER:0:2}" == "Xr8" ]; then
         export TOOLCHAIN_PREFIX=arm-linux-androideabi
         export TOOLCHAIN_VERSION=4.4.3
     elif  [ "X${ANDROIDNDKVER:0:2}" == "Xr9" ]; then
         export TOOLCHAIN_PREFIX=arm-linux-androideabi
         export TOOLCHAIN_VERSION=4.8
     elif [ "X${ANDROIDNDKVER:0:3}" == "Xr10" ]; then
         export TOOLCHAIN_PREFIX=arm-linux-androideabi
         export TOOLCHAIN_VERSION=4.9
         echo "Error: Please report issue to enable support for newer ndk."
         exit 1


     # search compiler in the path, to fail now instead of later.
     CC=$(which $TOOLCHAIN_PREFIX-gcc)
     if [ "X$CC" == "X" ]; then
         error "Unable to find compiler ($TOOLCHAIN_PREFIX-gcc) !!"
         error "1. Ensure that SDK/NDK paths are correct"
         error "2. Ensure that you've the Android API $ANDROIDAPI SDK 
Platform (via android tool)"
         exit 1
         debug "Compiler found at $CC"

     export CC="$TOOLCHAIN_PREFIX-gcc $CFLAGS"
     export AR="$TOOLCHAIN_PREFIX-ar"
     export RANLIB="$TOOLCHAIN_PREFIX-ranlib"
     export LD="$TOOLCHAIN_PREFIX-ld"
     export STRIP="$TOOLCHAIN_PREFIX-strip --strip-unneeded"
     export MAKE="make -j5"
     export READELF="$TOOLCHAIN_PREFIX-readelf"

     # This will need to be updated to support Python versions other 
than 2.7
     export BUILDLIB_PATH="$BUILD_hostpython/build/lib.linux-`uname 

     # Use ccache ?
     which ccache &>/dev/null
     if [ $? -eq 0 ]; then
         export CC="ccache $CC"
         export CXX="ccache $CXX"

Le 10/08/2015 10:49, Phil Thompson a écrit :
> On 10/08/2015 8:37 am, Sébastien RAMAGE wrote:
>> So having pyjnius could be awesome and this fork of pyjnius seems to
>> python3.4 compatible ^^
>> https://github.com/physion/pyjnius
>> I really want to help, but I don't know how I can try to compile it ? 
>> Any tips ?
> If you can identify what steps need to be taken, rather than the 
> details of how to actually do it, for example...
> The Cython source file that needs converting to C.
> The C files (generated or otherwise) that need compiling.
> Any .py files that need including.
> Any additional include directories that need to be searched.
> Any additional libraries that need to be linked.
> I can then see how to add general support for Cython extensions to 
> pyqtdeploy.
> Phil
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150810/f876cf25/attachment.html>

More information about the PyQt mailing list