Tuesday, November 29, 2011

Building .deb packages from Python packages

I needed to package a program written in Python to be deployed on Ubuntu 10.04, so I needed to create .deb packages from my Python packages, and their corresponding setup.py scripts. While most the python library dependencies were available through apt, they were all out of date. I needed to find a quick easy way to take Python Packages and deploy them to Ubuntu... Most of the blog posts I found had some insanely complicated and involved methods to do this. Then, while searching PyPI , I came across stdeb. Although it doesn't appear to be in active development it worked incredibly well.


Building .deb packages from Python packages is actually really easy. The python-stdeb is in the Ubuntu APT Repository, so it was easy to:
sudo apt-get install python-stdeb

To demonstrate the most simplistic case, here is what I did to generate an updated objgraph package:

wget http://pypi.python.org/packages/source/o/objgraph/objgraph-1.7.0.tar.gz#md5=7dee71c57d133bf80fa979bf771421ba
py2dsc objgraph-1.7.0.tar.gz
cd deb_dist/objgraph-1.7.0/
dpkg-buildpackage

Which left me with a python-objgraph_1.7.0-1_all.deb package in the parent directory.

No comments: