Python/Harmattan/Documentation for pyside-assistant


[edit] Setting up

[edit] Installing from Ubuntu PPA

If you are using Ubuntu then you can add PySide's ppa and get pyside-assistant from there:

sudo add-apt-repository ppa:pyside

If you're using Ubuntu Oneiric you have to add this to /etc/apt/sources.list.d/pyside-ppa-oneiric.list

deb natty main

Then run

sudo apt-get update
sudo apt-get install pyside-assistant

[edit] Building and installing from source

To build and install pyside-assistant you will need a Debian-based Linux distribution. First, install python2.6, sharutils and python-stdeb packages, that are runtime dependencies of pyside-assistant. Get the source from the Github page, then in the directory which pyside-assistant was downloaded, run:

    $ dpkg-buildpackage -D -rfakeroot -us -uc

Warning: Do not install python-stdeb from the git sources, or pyside-assistant will not work properly! The version from Debian and Ubuntu (0.6.0+20100620-1) works as expected.

Now go back a directory level and install the binary package:

    $ sudo dpkg -i pyside-assistant_<version>_all.deb

[edit] Usage Instructions

The main script for using pyside-assistant is psa.

[edit] list command

The list command lists all templates available.

    $ psa list

Currently available templates are:

For N900 devices.
For N9/N950 devices.
Ubuntu project using QML for user interface.
Ubuntu project using QtGui for user interface.

[edit] init command

The init command creates a project from the templates. It receives two mandatory arguments: a string that identifies the entire project, called project slug, and the target template (e.g. harmattan). The following call will create a project in the current directory with the project slug sampleproject:

    $ psa init sampleproject harmattan

All project files will be contained in a directory named after the project slug, which in this case is sampleproject. Additional parameters can be passed to psa init to set various fields from the start; these parameters are shown below:

    -a APPNAME, --app-name=APPNAME
                        Human-readable application name, refers to the Name field of sampleproject.desktop
    -s SECTION, --section=SECTION
                        Application section, refers to the section field of stdeb.cfg
    -d DESC, --description=DESC
                        Application short description, refers to the description field of
    -c CATEGORY, --category=CATEGORY
                        Application category, refers to the appname field of sampleproject.desktop

The created projects come with a file called README.assistant, which lists what each file does. The contents of this file is listed below:

README - pyside-assistant generated files

All files generated by psa init are described below. The sampleproject
slug used for them was 'sampleproject', with the following psa call:

    $ psa init sampleproject <fremantle|harmattan|...>

To list all available templates, use:

    $ psa list

* Distutils considers a list of files by default for
installation, listed at [1].  Additional files to be distributed
must be supplied in the file. The generated file includes
the .desktop file and any QML files found.


* The main file for using Distutils, contains most of the
information needed to build the package. Information about
can be found at
Two fields of this file can be modified by psa update parameters:
 - description: -d or --description
 - long_description: the contents of sampleproject.longdesc are used

* stdeb.cfg: Configuration file for stdeb, specifying additional
parameters for the binary package. The specification for this
file can be found at, in the section
stdeb.cfg configuration file. One field of this file can be modified by
psa update parameters:
 - Section: -s or --section

Note that the section should be a valid one,
as specified in

* sampleproject.aegis: Sample credentials file, which initially is empty. Information
of how to populate it can be found at [2].
NOTE: this file is used only in harmattan projects.


* sampleproject.desktop: This file specifies how to run the application
from the application grid, with various fields. Information about
.desktop files can be found at
Two fields of this file can be modified by psa update parameters:
 - Name: -a or --app-name
 - Category: -c or --category

Note that the category should be a valid one, as specified in

* sampleproject.png: The application icon, which is displayed in the
application grid.

* qml/*.qml: The QML files for the application. Their contents depend
on the platform.

* sampleproject: Main program. Initializes the application and provide
support for displaying the QML files contents.

* sampleproject.longdesc: Holds the contents of the long_description field of, which as the name implies is a more detailed description of what the project is.

[edit] build-deb command

The build-deb command does all necessary steps for generating a binary package. It essentially calls stdeb to build the proper Debian package and then places the application icons inside it. For using this command, you just have to enter the project directory and run:

    $ psa build-deb

The binary package will be found under the ./deb_dist directory.

If you want to add credentials to your project, you have to edit the .aegis file, which initially is empty and thus ignored. After you write all the necessary credentials to the file it will be injected into the binary package the next time the build-deb command is called. More information about credentials can be found here

[edit] update command

The update command can change certain values inside the project files, minimizing the need to open and edit them directly. This command accepts the following parameters:

    -a APPNAME, --app-name=APPNAME
                        Human-readable application name, resides in sampleproject.desktop
    -s SECTION, --section=SECTION
                        Application section, resides in stdeb.cfg
    -d DESC, --description=DESC
                        Application short description, resides in
    -c CATEGORY, --category=CATEGORY
                        Application category, resides in sampleproject.desktop

These parameters can be used in any order. As an example, to change the description and section of the project, run:

    $ psa update -d "Sample project" -s games

[edit] Example workflow

$ psa init sampleproject harmattan
$ cd sampleproject
(... hack ...)
$ psa build-deb
(... copy binary package to destination and install it ...)
(... hack some more ...)
$ psa update -c AudioVideo -s graphics
$ psa build-deb

(and so on.)

[edit] Packaging generic Python applications

pyside-assistant was initially conceived for creating PySide applications, but in fact it can be used to build binary packages for any pure Python application that uses Python Distutils.

For that purpose, follow these steps:

  • Run psa init as usual, to create the initial project layout;
  • Erase the qml directory, as its files are specific to Qt programs;
  • Create or add all files of your Python application;
  • Edit stdeb.cfg and replace the contents of the Depends field with the correct runtime dependencies for your application, if any.
  • If you don't have a file for your project, edit the provided one removing the .qml file reference and adding any other project files you need. See the Python Distutils documentation to know how the file works and how to edit it.

From now on, the same workflow applies: modify files, build binary package with psa build-deb, update fields with psa update, and so on.