I got a lot of great feedback on my buildout tutorial I posted last week. In general, the comments there have some excellent tips, tricks, and extra pointer, so check ‘em out.
After reading the comments and a few more I got over email, I thought I’d share a selected grab-bag of updates, hints, and details for those fooling around with Buildout and Django.
Django trove identifier
James Bennett pointed out that Django has its very own PyPI classification, Framework :: Django. It’s a good point: anyone posting Django-related packages to the cheeseshop ought to make sure that the list of classifiers in setup.py includes the Django classifier.
It looks like most folks are already doing this: right now there are 146 packages tagged with the Django classifier.
Testing against multiple versions of Django
Turns out there’s a neat trick you can use to develop/test against multiple versions of Django. This is a good idea: there’s supposed to be API stability between Django 1.0 and the forthcoming Django 1.1, but… well, “trust but verify.”
All you need to do is use multiple djangorecipe blocks:
[django-1.0]
recipe = djangorecipe
version = 1.0.2
projectegg = shorturls
project = shorturls
settings = testsettings
test = shorturls
testrunner = test-1.0
eggs = ${buildout:eggs}
[django-trunk]
recipe = djangorecipe
version = trunk
projectegg = shorturls
project = shorturls
settings = testsettings
test = shorturls
testrunner = test-trunk
eggs = ${buildout:eggs}
With that, you can easily run ./bin/test-trunk and ./bin/test-1.0 to test against both versions.
Certainly makes me happy.
Dependancies
Kevin Teague reminded me that listing eggs in the install_requires field of setup.py instead of buildout:eggs is a better way of managing dependancies: packages listed in install_requires get installed automatically by your users, whereas ones in the Buildout only get installed by you, locally.
Kevin also suggested that I list Django as a dependancy in install_requires. I’m actually not sure about this idea though: lots of people — me included — install Django through other means (djangorecipe, direct from source, etc.), so listing it as a hard dependancy means those folks will get an install of Django forced that they may not want. Indeed, listing Django as a dependancy breaks the multiple version trick I just shared.
Application templates
I got a few suggestions of ways to automate creation of the app environment. There’s a lot of options in this area:
- Paste, and templates based on it like fez.djangoskel or the unfortunately-named jkm.buildout.template written to match my previous post.
- Paver.
- The collective.recipe.template Buildout recipe, which can be used to bootstrap new packages.
HISTORY
A few people (Kevin, again, and someone else over email who’ve I’ve forgotten) also suggested that a good application template ought to include a HISTORY or CHANGELOG file along with the README.
Personally, I’ve never seen the point: for granular change history you’ll want to consult the revision control system, and each new version ought to come with high-level release notes as part of the docs. However, it’s not like having a HISTORY is going to hurt, so it’s worth considering.
Whiskey
I’m amazed by how many Pythonistas are also whiskey snobs. Suggestions included the Glenfiddich 30, which is fantastic, and the Macallan 12, which I have yet to try. But I will keep drinking my whiskey on the rocks, thank you very much.
Comments:
I do like the scotch, but your original post mentioned a bourbon. If you're more of a bourbon guy (like myself), I highly recommend Blanton's (http://www.blantonsbourbon.com) if you haven't tried it.
Thanks again for the excellent series on buildout.
I've enjoyed your series (can two posts be called a series?) of posts about zc.buildout.
I'd like to mention the z3c.recipe.tag recipe. It builts a ctags database for all the Python files from all the eggs mentioned in the recipe (including their dependencies), letting you find the definition of any class/function with a single keystroke in vim/emacs. Here's how you use it:
[ctags]
recipe = z3c.recipe.tag:tags
eggs = ${buildout:eggs}
add 'ctags' to the 'parts' list in [buildout], then rerun bin/buildout and run bin/ctags.
Another use for ~/.buildout/default.cfg is if you are using Buildout for production deployments, then you may use some mix of the following options for the account your are deploying with:
[buildout]
newest = false
offline = true
prefer-final = true
With "newest = false", Buildout will avoid attempting to check the internet for newer versions of an already installed package. "offline = true" goes one step farther and will run the Buildout without using any internet access (usually used in conjunction with the find-links option so that you can tell Buildout where your local files to install from are). Finally, "prefer-final = true" will avoid upgrading to any release marked with "dev|alpha|beta|etc".
(Although I don't usually use those options on a per account basis in production, and tend to instead prefer to maintain an explicit production buildout.cfg file for each deployment.)
With HISTORY.txt, the point to maintaining this file is that it *is* used to generate high-level release notes (or perhaps more accurately "medium-level" release notes). For example, to include these notes on a project's PyPI page, one can do:
long_description=(
open(os.path.join('HISTORY.txt')).read()
)
This is a nice idiom used with most projects in the Zope world, since you can quickly discover what's new between a release you are using and the latest version by visiting it's PyPI page.
I lost my "whiskey snob" license when I chose 12 year old Glenmorangie over 18 year old Glenmorangie in a blind taste test! But I recently found out that 15 year old Glen Garioch really hits the spot for my taste buds! In addition to a fine, clear flavour this scotch is one of the few that still comes in a traditional tartan-patterned bottle.
"Dependancies" s/b "Dependencies". Sorry, I grew up with English teachers.
Thanks for the post, anyway.
Mate you can't drink a single malt on the rocks!! In Scotland you'd be asked to leave the pub! :-) If you find the taste of the whisky (note the spelling - scottish is whisky, irish is whiskey) to overpowering you add room temperature water to it, just a dash or two until you find you can taste the whisky without the burn. Adding ice numbs the tongue which means you can't taste the whisky. Now, after my rant about that: good blog, am going to try buildout on my next project.
Leave a comment: