I'm starting to play around with using buildout for Django. I'd like to use buildout as the main installation method for deploying projects and applications. In this context is it the best that each application contains a buildout, as well as the project? At what level开发者_StackOverflow社区 should you apply the buildout?
Thanks,
Todd
The way I usually set it up is like this:
buildout_dir/
+ bootstrap.py
+ buildout.cfg
+ ...
+ <project_name>/
+ settings.py
+ templates/
+ media/
+ ...
Since the buildout is (in my case) often tied to a single project anyway, I'll just store the django project directly inside the buildout. By the way: I'm using djangorecipe in my buildout configuration.
The applications I write are simple eggs and have this kind of layout:
django-<app_name>/
+ setup.py
+ <app_name>/
+ __init__.py
+ models.py
+ ...
But I've also seen apps that are a self contained buildout. Jacob Kaplan-Moss even wrote an article about it.
I always have at least two/three buildout configs at project (website) root:
/
|- buildout.cfg # contains bas configuration used by other cfg files
|- development.cfg # adds ton of eggs used only in development and generates manage script using djangorecipe
|- production.cfg # most of the time it contains versions and generates django script using djangorecipe
For me, I give every app and every project a buildout. The project's buildout is for, well, setting up the site. Including:
generating an apache/nginx config file (collective.recipe.template)
perhaps a cronjob
perhaps supervisor if you want to run a separate gunicorn or so.
Every app also has a buildout. Here the goal is to make it easy to set up an isolated environment especially for testing. You never need to deploy an app, you just need to get it set up enough to run the development server and to run the tests.
For me, buildout is isolation (like virtualenv) plus installation (like pip) plus project automation. You'll mostly use the first two for the apps. And all three for the site.
I always create a buildout per project that fetches all required dependencies. This can be simple eggs but also internal dependencies from git(hub) using mr.developer
I don't see a need to have a per-app buildout. It's probably good to have a matching buildout.cfg for each django settings configuration (e.g. development, production, etc)
The buildout is simply applied at the project folder, dependencies will automatically be included (and customizable when using mr.developer).
also, including bootstrap.py is a bit oldfashioned in my opinion; I always run virtualenv + pip install zc.buildout. This can also be done on the project folder itself, or externally (e.g. ~/virtualenvs/myproject-123)
精彩评论