/python-debian-packaging-example

Simple example of packaging a python app for debian using dh-virtualenv

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Example of packaging a python app as a .deb using dh-virtualenv

Overview

  • dh-virtualenv is a very neat way of packaging python into debs with the key advantage that these apps are packaged as a virtualenv so that the latest packages can be use without relying on the packages on the system... But system packages can also be used. A key advantage is that the latest python libraries can be used in a self contained way.
  • The dh-virtualenv documentation mainly focuses on terminal scripts and I couldn't find a good example of packaging an app.
  • So I've included one here that adds a terminal command as well as a desktop shortcut and icon.
  • The example I've used is from a previous blog post on pyside dragging and dropping

Setup for ubuntu 14.04

  • Install the python development packages
sudo apt-get install python-dev
  • Create a virtualenv (so that the latest pip and setuptools and activate
virtualenv virt-example
source ~/virt-example/bin/activate
pip install -U pip
pip install -U setuptools
  • Install the latest dh-virtualenv from source as discussed in step 1 of the dh-virtualenv instructions

  • Install pyside in your virtualenv (Requires Qt4)

  • Test that the script works before packaging it as a deb

python ExImView/image_app.py

Build the example debian package of the GUI

In the folder containing the source

dpkg-buildpackage -us -uc -b

This should build a debian outside the folder

For a full discussion on the setup and files, see the corresponding blog post.

Screenshots

Install the newly created debian

Image 0

The icon appears in search

Image 1

Once launched an icon appears in the dock

Image 2

The app functions as expected

Image 3

To uninstall the test app

sudo apt-get remove ExImView

Notes

Note that this example doesn't take advantage of the main use of dh-virtualenv, which is packaging the latest dependencies with the app. But this can be done trivially by adding them to the requirements.txt file as explained in the dh-virtualenv documentation.

Please suggest changes that improve this example