creating a debian package for python library

This as a quick and dirty (filthy) guide to creating a debian package for a pythin library stored in a git repository. I assume you have no gzip file to download and compile the which is what the standard package building tools expect. I used information here as a basis.

Dependencies:

  • python-stdeb
  • devscripts

In the root of your git repo run the following command to “debianize”.

python setup.py --command-packages=stdeb.command debianize

This will create a debian directory with a skeleton of things you need to make the package.

Change debian/src/format to use the git src format. Read up there as this is still a bit experimental.

3.0 (git)

Add a debian/copyright file especially if you intend to release your code publicly.

Now you have to add and commit the debian directory to build the package. This is a little weird but the build script is smart enough to check if you have uncommitted changes.

Run debuild to build the package. The –no-lintian option does not run lintian after dpkg-buildpackage. The -us and -uc ignores signing the deb and the changes file. If you have keys setup to sign the package leave those options out. Since I am doing all this in a debian virtual machine I am going to skip for now. Try not including the –no-lintian option to see what debuild complains about and fix it. That would be the less dirty way to do things.

debuild --no-lintian -uc -us

This should create a package one directory above your repository where you have been running all of these commands