chrisdew chrisdew - 3 months ago 17
Python Question

How do I do Debian packaging of a Python package?

I need to write, or find, a script to create a Debian package, using python-support, from a Python package. The Python package will be pure Python with no C extensions.

The Python package for testing purposes will just be a directory with an empty

__init__.py
file and a single Python module,
package_test.py
.

The packaging script must use python-support to provide the correct bytecode for possible multiple installations of Python on a target platform, i.e. v2.5 and v2.6 on Ubuntu Jaunty.

Most advice I find while googling are just examples of nasty hacks that don't even use python-support or python-central.

I have spent hours researching this, and the best I can come up with is to hack around the script from an existing open source project, but I don't know which bits are required for what I'm doing.

Has anyone here made a Debian package out of a Python package in a reasonably non-hacky way?

I'm starting to think that it will take me more than a week to go from no knowledge of Debian packaging and python-support to getting a working script. How long has it taken others?

Answer

I would take the sources of an existing Debian package, and replace the actual package in it with your package. To find a list of packages that depend on python-support, do

 apt-cache rdepends python-support

Pick a package that is Architecture: all, so that it is a pure-Python package. Going through this list, I found that e.g. python-flup might be a good starting point. To get the source of one such package, do

apt-get source <package>

To build it, do

cd <packagesrc>
dpkg-buildpackage -rfakeroot

When editing it, expect that you only need the files in the debian folder; replace all references to flup with your own package name.

Once you get started, it should take you a day to complete.