setup.py install and bdist_egg
jasiu85 at gmail.com
Fri Mar 13 21:41:12 CET 2009
I work at a company where I'm lucky enough to write web apps using
Python and WSGI :). We develop more and more stuff in Python and it's
becoming a mess of dependencies, so we thought we would create a
guideline for developers that describes the whole process of deploying
a Python app on a server. Since all of our servers run Debian, all of
our software has to be installed as Debian packages - other
departments that don't use Python (shame on them! :D) already follow
Here is what we have figured so far:
1) Write your code.
2) Prepare setup.py, and put names of required eggs in there.
3) Write a Debian wrapper that uses CDBS Python class, and put names
of required Debian packages in there.
4) Build Debian package.
5) Done! Deploy on server and have fun :).
This guideline already works pretty well for us, but I thought I could
tweak it a little. I want to make the Debian package wrapper as thin
as possible so that if we ever stop using Debian, we will still be
able to deploy all of our software as eggs. This goal turned to be
pretty challenging. I have a few questions.
1) Debian has a debian/dirs file where you can list all the
directories that the package should create, for example those in /var/
log, /var/lib . I already figured out that I can use setup.py
'install_data' keyword for that, even for empty directories. Then I
can use 'setup.py install' command and things work great. But... How
about eggs? I'd like my egg to somehow contain or create such
directories. For example, I have a config file that I want to place
in /etc directory. I can do that using 'setup.py install', but
'setup.py bdist_egg' will just create an egg containing etc/
directory. Can I do something about it? Also, why doesn't an egg
contain empty dirs that I place in install_data?
2) What about file permissions? Can they be set by setup.py? My
software runs as www-data user and so /var/log and /var/lib
directories should have proper owner, group and permissions. I didn't
figure out a way to change permissions using setup.py. In Debian I can
use postinst script for that.
If anything sounds unclear, blame my bad english :).
More information about the Python-list