1. Peter Hansen
  2. blackberry-py


Clone wiki

blackberry-py / Building PySide

Building PySide

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:

  1. Configure your development environment.
  2. Install a host version of Shiboken (used during the build process).
  3. Get the Qt 4.8 libraries and headers.
  4. Get PySide and Shiboken (for libshiboken) sources.
  5. Apply our patches to PySide and Shiboken.
  6. Configure and make libshiboken and PySide.
  7. Package binaries for transfer to your app development machine.
  8. Done!

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.

Configuring Ubuntu

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:

  • /usr/lib/libpython3.2m.so.1.0
  • /usr/include/python3.2m/pyconfig.h

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 \
-DLIB_INSTALL_DIR=~/dev/stage \
-DCMAKE_C_COMPILER="$QNX_HOST/usr/bin/ntoarmv7-gcc" \
-DCMAKE_CXX_COMPILER="$QNX_HOST/usr/bin/ntoarmv7-g++" \
-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_C_COMPILER="$QNX_HOST/usr/bin/ntoarmv7-gcc" \
-DCMAKE_CXX_COMPILER="$QNX_HOST/usr/bin/ntoarmv7-g++" \
-DShiboken_DIR=~/dev/shiboken-build/data \
-DSHIBOKEN_INCLUDE_DIR=~/dev/stage/include/shiboken \

# 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.