tags:

views:

340

answers:

5

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 (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 nasty hacks that don't even use python-support or python-central.

I have so far 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?

Any advice?

Chris.

+2  A: 

First off, there are plenty of Python packages already in Debian; you can download the source (including all the packaging) for any of them either using apt-get source or by visiting http://packages.debian.org.

You may find the following resources of use:

derobert
+2  A: 

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.

Martin v. Löwis
A: 

I've crafted a couple of different ways using Python. One example (which you would most probably need to adapt to fit your needs ;-) is available here.

jldupont
+1  A: 

I think what you want is http://pypi.python.org/pypi/stdeb:

stdeb produces Debian source packages from Python packages via a new distutils command, sdist_dsc. Automatic defaults are provided for the Debian package, but many aspects of the resulting package can be customized (see the customizing section, below). An additional command, bdist_deb, creates a Debian binary package, a .deb file.

Nikratio
+1  A: 

Here's a wonderful guide. My comment on that post has some useful suggestions.

Tshepang