Reference Django application for building Debian packages.
All feedback or enhancements appreciated!
To follow some Debian packaging guides as well as LSB/FHS standards, following hierarchy is used for Django installations:
||Virtualenv root, this is read-only place where app ant it's
Additional scripts like
||Variable files, media and statically served files.
Static files are collected during package configuration with
||Configuration directory, place for overrides of default configuration, shipped with package. This configuration is also managed by debconf.|
||Optional place for sysadmin maintained templates.|
||All support files that are not being changed over time and are not
binaries or libraries should belong to
||Place for non-syslog log files. Debconf script will set correct
permissions on directory and
||Additional documentation, readme, debian changelog, etc.|
Sane defaults should be already part of distribution and set in
django_helpdesk.settings and eventually
django_helpdesk.celery_settings. At best it should be defaults that will
run on any machine without additional configuration.
Default settings can be overriden in:
- this is sourced by
- it could be also
/etc/default/django-debianas it contains common and startup settings for application
- this is sourced by
These configuration files are included from distribution
following simple mechanism:
try: with open("/etc/django-debian/settings.py") as f: code = compile(f.read(), "/etc/django-debian/settings.py", 'exec') exec(code) except IOError: pass
Alternatively it can support configuration overrides in some common configuration format, like yaml, ini, etc.
Some basic configuration is done immediately after package installation or
For more informations see
To build version in current branch, you should use git-buildpackage and pbuilder. Pbuilder will create clean chroot environment and install required dependencies so you don't need to mess up your system.
Alternatively you can install build dependencies on your own and execute plain
dpkg-buildpackage -uc -us
- Install required packages
apt-get install cowbuilder pbuilder git-buildpackage dh-virtualenv dh-python
In case you are building whole virtualenv, you need latest dh-virtualenv (latest master, unreleased version 0.10) with support for overriding destination directory. This package is built in our repository but it probably won't be present in your OS distribution. Install it manually from our repo or build it on your own from https://github.com/spotify/dh-virtualenv
- Configure pbuilder to allow network access (dh-virtualenv only)
Create or edit
~/.pbuilderrcand put following inside:
- Create cowbuilder environment
- Build the package
git-buildpackage --git-pbuilder -uc -us --git-ignore-branch
That will create source archive and run pbuilder which will create chroot, You need to commit or stash all your changes first.
- setup gunicorn and optionally nginx or apache
- setup database with dbconfig-common