wiki:PySideForAndroid

Version 5 (modified by Martin Kolman, 11 years ago) (diff)

--

PySide for Android

This guide describes:

  • how to build Shiboken & PySide for Android using the Necessitas SDK
  • how to use the resulting libraries
  • and how to bundle them with your Python program in a standalone APK

NOTE: If you just wan't to run you Python & PySide programs on Android, you can skip the Building PySide section.

Do you see something incorrect or missing from the guide ? Let me know, so I can fix it ! :)

Building PySide

Preparation

First install the prerequisites:

  • Necessitas SDK

(make sure you have the Android SDK platform 14 installed in it)

  • system-wide installed Shiboken
  • system-wide installed Python 2.7
  • Python 2.7 compiled for Android
  • cmake
  • git

This command should probably fetch most of the prerequisites on Ubuntu:

sudo apt-get install build-essential cmake git python2.7-minimal shiboken

If you find some are is missing or if you wan't to provide similar command for other distributions, let me know ! :)

Then clone the Android-pyside-build-scripts project and cd to it's directory:

git clone git@github.com:M4rtinK/android-pyside-build-scripts.git
cd android-pyside-build-scripts

Now run the prepare.sh script:

./prepare.sh

It clones Android-modified Shiboken & PySide and creates some folders needed for the build.

And that's it, you are ready to start the build. :)

Build

To start the build, just run the main build script, called build.sh:

./build.sh

It first builds Shiboken, followed by PySide. The script is fully automatic, but waits for the user to press any key:

  • after Shiboken is configured for build
  • after Pyside is configured for build

Like this you can easily check for any errors during configuration.

Also note, that when running the script, it clears any previous build results before building.

You can also run the build_shiboken.sh and build_pyside.sh scripts manually, just always make sure to run the Shiboken one before running the PySide one.

Results

The resulting PySide libraries compiled for Android are located in the stage/lib folder.

PySide for Android example

This is an example, that demonstrates a fully functional standalone Android application that uses Python, PySide and Qt Components.

APK

Acknowledgement

As usual with open source development, I haven't done all of this single handedly, but built on work done by others previously. So I'd like to both acknowledge on which work this is build upon and also provided links to the sources I've used:

Thanks a lot - without you, this would not be possible! :)