2. Django
• Web Framework in Python
• MVC
• ... has tons of great features that are
actually not really relevant for the topic at
hand
• Summary: <3
2
3. Django and its libs
• What do we usually need ...
• Django
• django-tagging
• django-threadedcomments
• (if things like DB-bindings are already
installed)
3
4. All of that you have to
install on ...
• ... your own machine
• ... your server
• ... and basically every other machine that has
anything to do with the development
4
5. Installing from & with ...
• Straight from an SCM-checkout
• Sadly that’s still very common since the apps
are still quite young
• Using a setup.py
• Using setuptools and easy_install (PyPI <3)
5
6. Being root helps
• You have to either install these libraries as
root user
• ... or you have to start messing around with
the PYTHONPATH
• ... which normally results in just a big
mess
6
7. virtualenv
• virtualenv lets you $ virtualenv myenv
install Python packages
without being root $ source myenv/bin/activate
• It lets you build
$ cd /some/lib
$ python setup.py install
environments for those
....
packages that you load
at will $ deactivate
Photo: http://flickr.com/photos/fensterbme/145621388/
7
8. virtualenv
• ... is a great tool if you want to try a new
library
• But it doesn’t solve the problem that you have
to manually reconstruct the environment
every time.
• The environments are not portable (C-
extensions?)
• ... and not moveable (experimental right now)
8
9. zc.buildout
• Buildout now lets you build a whole
environment with just one config-file
• Basically, it’s similar to Maven in the Java-world,
just without XML ;-)
• A project consists of multiple parts
• Each part defines, where its data is coming from
and where to store it
Photo: http://flickr.com/photos/mdpettitt/2521514631/
9
10. Recipes exist ...
• ... that download eggs and build a wrapped
interpreter to test them
• ... that download a source-distribution and
install it
• ... that checkout code from Subversion
• ... and much much more
10
11. A small example
$ buildout
>>> buildout.cfg PyPI Canonical
[buildout]
parts = sample
[sample]
recipe = zc.recipe.eggs
interpreter = myinterpreter
eggs =
storm==0.12
$./bin/myinterpreter
> from storm.locals import *
11
12. Buildout for Django
• What is in for Django developers?
• A simple way to install dependencies
• ... and to freeze them at a version
• ... and naturally really fast deployment (even
with a WSGI-script)
12
13. djangorecipe
• Recipe for Django projects by Jeroen
Vloothuis:
http://pypi.python.org/pypi/djangorecipe/
• Creates a Django project with a given
version
• ... and creates a wrapper for manage.py
with all eggs and other dependencies
loaded
13
14. Another example
[buildout]
parts = django svnapps
[django]
recipe = djangorecipe
version = 1.0
project = mysite
settings = settings
extra-paths =
${svnapps:location}/tagging
[svnapps]
recipe = iw.recipe.subversion
urls =
http://django-tagging.googlecode.com/svn/trunk/ tagging
14
16. mod_wsgi?
• djangorecipe can also be used to create a
WSGI-script
• Option: wsgi = true
• ./bin/django.wsgi
• Naturally also includes all the dependencies
16
17. Summary
• Buildout provides easy dependency management
from a multitude of sources (public or not and not
only with setuptools)
• Dependencies AND freezing of them
• For developing on a Django project all you need is
one buildout.cfg
• djangorecipe also provides you with a WSGI-script
• Migrating to it is very easy :-)
17