(As requested by Jean-Fred)
One of the ‘pain points’ with working on deploying python stuff at Wikimedia is that
virtualenvs are banned on production, for some (what I now understand as) good reasons (the solid Signing / Security issues with PYPI, and the slightly less solid but nonetheless valid ‘If we use pip for python and gem for ruby and npm for node, EXPLOSION OF PACKAGE MANAGERS and makes things harder to manage’). I was whining about how hard debian packaging was for quite a while without checking how easy/hard it was to package python specifically, and when I finally did, it turned out to be quite not that hard.
Really, that is it. Ignore most other things (until you run into issues that require them :P). It can translate most python packages that are packaged for PyPI into .debs that mostly pass lintian checks. Simplest way to package, that I’ve been following for a while is:
python-stdeb(from pip or apt). Usually requires the packages
build-essential, although for some reason these aren’t required by the debian package for
stdeb. Make sure you’re on the same distro you are building the package for.
git clonethe package from its source
python setup.py --command-packages=stdeb.command bdist_deb(or
python3if you want to make Python 3 package)
lintianon it. If it spots errors, go back and fix them, usually by editing the
setup.pyfile (or sometimes a
stdeb.cfgfile). This is usually rather obvious and easy enough to fix.
dpkg -i <package>to try to install the package. This will error out if it can’t find the packages that your package depends on. This means that they haven’t been packaged for debian yet. You can mostly fix this by finding that package, and making a deb for it, and installing it as well (recursively making debs for packages as you need them). While this sounds onerous, the fact is that most python packages already exist as deb packages and you
stdebwill just work for them. You might have to do this more if you’re packaging for an older distro (cough cough
precisecough cough), but is much easier on newer distros.
- Put your package in a repository! If you want to use this on Wikimedia Labs, you should use Labsdebrepo. Other environments will have similar ways to make the package available via
apt-get. Avoid the temptation to just
dpkg -iit on machines manually :)
That’s pretty much it! Much simpler than I originally expected, and not much confusing / conflicting docs. The docs for
stdeb are pretty nice and complete, so do read these!
Will update the post as I learn more.