This page documents how to build PySide for the PlayBook or BB10 using the Qt 4.8 source. We used Ubuntu, but it should be possible to adapt these instructions for any suitable environment.
The basic process involves the following steps:
- Configure your development environment.
- Install a host version of Shiboken (used during the build process).
- Get the Qt 4.8 libraries and headers.
- Get PySide and Shiboken (for libshiboken) sources.
- Apply our patches to PySide and Shiboken.
- Configure and make libshiboken and PySide.
- Package binaries for transfer to your app development machine.
If you don't have an appropriate build machine handy, you can set up a VPS easily and cheaply with a service like Rackspace. Our build machine is a Rackspace VPS with 256MB of RAM, installed with Ubuntu 12.04.
Setting up a Linux build machine can be fun and educational, but we'll to defer to online tutorials for how to do that as it involves a few things (e.g. SSH) which aren't entirely trivial.
We're providing pre-built install packages so you don't need to build this yourself unless you want to.
Install the development tools:
# basic stuff needed (note use of "sudo" since you should not work as root!) sudo apt-get install build-essential cmake git mercurial sudo apt-get install python3-minimal shiboken # if you're on a 64-bit build you need this for the NDK sudo apt-get install ia32-libs # we're not sure this is required, but it shut up some errors # during the PySide build on Ubuntu 12.04 LTS (our build machine) sudo apt-get install libicu48 # get NDK, and Python source mkdir ~/downloads wget -P ~/downloads https://bdsc.webapps.blackberry.com/native/downloads/fetch/installer-bbndk-2.0.1-linux-358-201202171813-201204101541.bin wget -P ~/downloads http://www.python.org/ftp/python/3.2.3/Python-3.2.3.tar.bz2 # install NDK, specifying defaults for all values sh ~/downloads/installer-bbndk-2.0.1-linux-358-201202171813-201204101541.bin source ~/bbndk-2.0.1/bbndk-env.sh
Retrieve and set up various source packages:
# we do dev in a subfolder to keep it organized mkdir ~/dev cd ~/dev tar xjf ~/downloads/Python-3.2.3.tar.bz2 # get latest versions of everything we need # Note: we actually used Qt 4.8.2 which is # http://qt.gitorious.org/qt/qt/commit/f1a55ad65337bb614c3dd6e723554bded72a28e4 git clone git://gitorious.org/qt/qt.git # we used PySide commit ee95e881929b3b51e535ad9024025cc7ac91d57c git clone git://gitorious.org/pyside/pyside.git # we used Shiboken commit 54cce10fa8a9942450c9e1a9d9a9d2a1b688f243 git clone git://gitorious.org/pyside/shiboken.git hg clone https://bitbucket.org/microcode/blackberry-py
To build Qt we basically follow the instructions from http://qt-project.org/wiki/QNX
cd qt ./configure -opensource -confirm-license -qpa -iconv -shared -release -xplatform \ unsupported/blackberry-armv7le-qcc -little-endian -arch arm -largefile -nomake examples \ -nomake demos -xmlpatterns -no-webkit -no-neon -no-rpath -opengl es2 -prefix-install -prefix ~/dev/qt-arm make -j2 make install cd .. export QTDIR=~/dev/qt-arm # you may also wish to add that to the end of your .bashrc so it's set # for later logins
To build PySide we'll need a couple of things from the target. SSH into your PlayBook and extract the following files:
Transfer those to your development machine for the next steps. We'll assume you've placed them in ~~/dev. Note that the patch for shiboken means we build only libshiboken for the target. The shiboken binary itself, which is needed during the following PySide build, was installed for the host using the apt-get command earlier.
cd ~/dev # put target's Python config header in Python source folder cp pyconfig.h Python-3.2.3/Include # build libshiboken (our patch skips shiboken itself) mkdir shiboken-build cd shiboken git apply ~/dev/blackberry-py/patches/01-shiboken-qnx.patch cd ../shiboken-build cmake ../shiboken \ -DCMAKE_INSTALL_PREFIX=~/dev/stage \ -DLIB_INSTALL_DIR=~/dev/stage \ -DCMAKE_BUILD_TYPE=MinSizeRel \ -DENABLE_ICECC=0 \ -DCMAKE_C_COMPILER="$QNX_HOST/usr/bin/ntoarmv7-gcc" \ -DCMAKE_CXX_COMPILER="$QNX_HOST/usr/bin/ntoarmv7-g++" \ -DCMAKE_SYSTEM="QNX 6.5.0" -DCMAKE_SYSTEM_NAME="QNX" \ -DCMAKE_SYSTEM_PROCESSOR="arm" -DCMAKE_CXX_FLAGS="-fPIC" \ -DLIBXML2_INCLUDE_DIR="$QNX_TARGET/usr/include" \ -DLIBXSLT_INCLUDE_DIR="$QNX_TARGET/usr/include" \ -DLIBXML2_LIBRARIES="$QNX_TARGET/armle-v7/usr/lib/libxml2.so" \ -DLIBXSLT_LIBRARIES="$QNX_TARGET/armle-v7/usr/lib/libxslt.so" \ -DPYTHON3_LIBRARY=~/dev/libpython3.2m.so.1.0 \ -DPYTHON3_INCLUDE_DIR=~/dev/Python-3.2.3/Include \ -DBUILD_TESTS="false" -DUSE_PYTHON3="true" make -j2 make install cd ~/dev mkdir pyside-build cd pyside git apply ~/dev/blackberry-py/patches/02-pyside-qnx.patch cd ../pyside-build cmake ../pyside \ -DCMAKE_INSTALL_PREFIX=~/dev/stage \ -DCMAKE_BUILD_TYPE=MinSizeRel \ -DENABLE_ICECC=0 \ -DCMAKE_C_COMPILER="$QNX_HOST/usr/bin/ntoarmv7-gcc" \ -DCMAKE_CXX_COMPILER="$QNX_HOST/usr/bin/ntoarmv7-g++" \ -DCMAKE_SYSTEM="QNX 6.5.0" -DCMAKE_SYSTEM_NAME="QNX" \ -DCMAKE_SYSTEM_PROCESSOR="arm" -DCMAKE_CXX_FLAGS="-fPIC" \ -DBUILD_TESTS=false \ -DShiboken_DIR=~/dev/shiboken-build/data \ -DSHIBOKEN_INCLUDE_DIR=~/dev/stage/include/shiboken \ -DCMAKE_INSTALL_PREFIX=~/dev/stage make # this will crash after a few files, with an error, so run this next: find . -name "build.make" -print | xargs \ sed -i 's;'$HOME'/dev/stage/bin/SHIBOKEN_GENERATOR-NOTFOUND;/usr/bin/shiboken;g' make -j2 make install cd ~/dev
At this point you should have complete libraries for Qt and PySide, so we just need to package them up for use in your apps. We've made a small utility that can do the job conveniently.
cd ~/dev python blackberry-py/bin/bbpy-pyside-packager.py qt-arm stage
You should now have blackberry-py-full.tar.bz2 in your ~~/dev folder!
To make apps with it, start by reading PySide Building HelloWorld.