This page is an attempt to take the discussion on Python Packaging on the Ubuntu wiki ( and turn it into a tutorial without all the extra chatting. :)

Getting Started

First, grab the necessary packages:

sudo aptitude install wget dh-make devscripts

Then, prepare the working area:

mkdir ~/python-packaging && cd ~/python-packaging

Preparing your app

Like the chat, we'll use terminator from ( as our example.

1. Make a tarball of your app. (you can get terminator's by doing (wget

2. Rename it to <name>_<version>.orig.tar.gz

 mv terminator_0.8.1.tar.gz terminator_0.8.1.orig.tar.gz 

3. Unpack the tarball to work on it and go into that dir

tar -xf terminator_0.8.1.orig.tar.gz
cd terminator-0.8.1/

4. Use dh_make to create a template package to start from

 dh_make -c gpl -s -b 

The options in this case mean the following:

-c - sets the license of the package, in this case, gpl

-s - tells it to build only one binary package (i.e. we don't need a -docs, -common, -dev, etc. package)

-b - "tells it to use CDBS, 'Common Debian Build System', which will make our packaging simple, so we can concentrate on the Python specific things."

5. Go into the debian folder it created and remove the *.ex files, which are example scripts that we don't need in this case.

cd debian/
rm *ex *EX

6. Now it's time to edit the control file. Open it in the editor of your choice (you can do "gedit control" if you're new to Linux). The control file has two parts. The first part specifies the source package info, the rest specifies the binary package info (in our case just one). The important fields to fill in are:

Section - in this example we will use 'misc', the list of possible options is here: ( Python modules (not apps) should use 'python'

Priority - should be optional in this case, extra is used for -dev, -dbg, and some others

Standards-Version - should be 3.7.3, the default of 3.7.2 is probably okay, but you should always use the latest version

Architecture - should be 'all' for pure Python scripts, otherwise a list of architectures the app runs on.

Description - first line is a short description, all subsequent lines (indented by one space) are the long description.

Build-Depends - put the list of Ubuntu packages needed to build the software here

Depends - put the list of Ubuntu packages (including any 3rd party Python modules) needed to run the software here

(Note: Python apps need to add ${python:Depends} here. Also, a good way to find package names for 3rd party python modules is to do a search using  apt-cache search module | grep python .)

Suggests - put a list of any packages which are useful, but not necessary, here

Recommends - put a list of any packages which are useful, and will be installed unless the user refuses them, here

Python apps also need to add the following field:

XB-Python-Version - Sets the Python version(s) the apps work with. In this case, we just use ${python:Versions}

7. Follow the steps specified by

In this case, we will use the python-central method, so follow the steps outlined in "Updating your packages" and "Using python-central".

Ubuntu Packaging Guide (last edited 2008-05-05 01:39:01 by ip68-108-6-71)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.