Back to index
zc.buildout is EPIC!

Last week we had a nice session of zc.buildout and other ZTK basics by Joe Steeve at our alma mater. To put that listening to good use, I decided to hack my dumBBlogger to use zc.buildout. Another reason is as I don't have a laptop, whenever I go and start using a new machine and want to do a blog, I have to take all the pain to setup my blogging tool manually. I wanted to automate this stuff. zc.buildout proved to be a nice solution for that. Now to the setup story,

My blog tool is basically has a core file which does all the work of finding the posts, rendering it, writing out as html etc. Then there is a configure script which writes out a Makefile( I use the makefile for dependency based building. That is if a blog post is changed only that post, the related tag pages, the archives page and the index page if neccessary are only reloaded. Other posts are left untouched.)

The Makefile will be of form

./build [command] 
   target(output html file) : dependent posts

That './build' is again a simple python script which calls the appropriate core function based on the [command]

Everytime I write a new post, I do

./configure && make

If I modify any post I'll do,


So the dumBBlogger is a set of some scripts which are called one after other. Now the most beautiful thing about zc.buildout is it creates a custom interpreter for us with all the dependency (modules/eggs/scripts) available for import.

To be brief, I created a buildout config to install all the dependencies, create a custom dumbblogger interpreter and used that interepreter path as a 'hashbang' in all my scripts. Voila! It's done :D

There is a wonderful tutorial about using zc.buildout for django by Jacob Kaplan Moss. So I created the initial directory structure and wrote a accordingly. I listed all the dependencies in the That can be found here. Then I wrote the buildout.cfg file as below,

parts = dumbblogger
develop = .
eggs = dumbblogger

recipe = zc.recipe.egg
eggs = ${buildout:eggs}
interpreter = dumbblogger

Now moved the source code into the src/ folder as it was a followed practice while using buildout. Then I ran this,

python && ./bin/buildout

That downloaded and installed all the dependencies as eggs and created a custom interpreter named dumbblogger. Then the last step I had to do is to change the hasbang in my scripts to use this custom interpreter, rather than the global python interpreter. See below,


#-- Mode:Python --

I made the same change in configure script and that's done :) Now wherever I go, I can just checkout my code from bitbucket, cd into it, do 'python && ./bin/buildout' and be done :D

The directory structure after everything is setup looks like below,

|-- bin
|   |-- buildout
|   -- dumbblogger
|-- buildout.cfg
|-- develop-eggs
|-- dumbblogger.egg-link
|-- eggs
|   |-- Mako-0.4.1-py2.6.egg
|   |-- Markdown-2.0.3-py2.6.egg
|   |-- MarkupSafe-0.12-py2.6-linux-x86_64.egg
|   |-- PyRSS2Gen-1.0.0-py2.6.egg
|   |-- python_dateutil-1.5-py2.6.egg
|   |-- setuptools-0.6c12dev_r88846-py2.6.egg
|   |-- zc.buildout-1.5.2-py2.6.egg
|   -- zc.recipe.egg-1.3.2-py2.6.egg
|-- parts
|-- buildout
|-- src
|   |-- dumbblogger
|   `-- dumbblogger.egg-info

You can see all the dependencies installed in the eggs folder, the custom interpreter in the bin folder and application code in the src folder.

I can still think of lot of automation here and will do it as and when the time permits.

Happy hacking :)

Published at : Tuesday Jul,12 2011 at 12:40 | Tags : hacking, python, dumbblogger, | Comments
blog comments powered by Disqus Browse Archives
I am..
Azhagu Selvan SP
Atheist, FOSS enthusiast,
Pythonist, Student
Creative Commons License