Friday, May 16, 2008

virtualenv, zc.buildout or how to develop python apps

i hope i will get some responses of others and how you develop in python, what software do you use, so it bring your devel-deploy story easier.

since your are in most cases working on several python apps that rearly have something incommon or they are suppose to work alone, is good the provide this application its own python environment. here you can use virtualenv and create virtual environment for out new app.

>> rok@bestia ~/Projects $ su -
>> Password:
>> root@bestia ~ # easy_install virtualenv
>> Searching for virtualenv
>> ...
>> root@bestia ~ # exit
>> logout
>> rok@bestia ~/Projects $ virtualenv --no-site-packages mynewapp
>> New python executable in mynewapp/bin/python
>> Installing setuptools.............done.
>> rok@bestia ~/Projects $ cd mynewapp/
>> rok@bestia ~/Projects/mynewapp $ source bin/activate
>> (mynewapp)rok@bestia ~/Projects/mynewapp $

and then to exit you virtualenv just do...

(mynewapp)rok@bestia ~/Projects/mynewapp $ deactivate
rok@bestia ~/Projects/mynewapp $

well thats it. you have a clean python environment (no other python packages), only setuptools is installed. and its ready to (ab)use it. its also possible to extend the creation of virtualenv with for example installation of your custom packages. only minus with virtualenv is that is not working under windows. well who is using windows anyway :)

its also a python development tool. and lately most popular egg in the cheeseshop, mostly because zope/plone ppl (like me) are using it for developing. it uses recipes which then installs your software, doesnt mather if its python app or some other app. by default you have some recipes that you can use, but its easily to write new ones.

!!! i use both virtualenv and zc.buildout for developing the same python app

>> (mynewapp)rok@bestia ~/Projects/mynewapp $ easy_install zc.buildout
>> (mynewapp)rok@bestia ~/Projects/mynewapp $ buildout init (or bootstrap if you already have configuration file)

then its up to you how/what you insert into your buildout.cfg. follow this link to learn more about the magic that zc.buildout does for you.


pokahontas said...

guess who? :)

sori za tako neumesen komentar a ne vem kako ti drugače naznaniti, da se skuša bivši 8.c po dolgem času spet srečati ...

da ne razglabljava o tem prek bloga ;) mi prosim pusti na moj mejl svojega, da ti posredujem vse informacije v primeru, da bi se nam želel pridružiti...

bivša sošolka :)

Rok Garbas said...


le katera sosolka se skriva za psevdonimom pokahontas? hehe...
ves da sem za to da se vidimo. nic tukaj je moj mejl pa mi pisi, tvojega nisi pustila nikjer, v profilu ga pa tudi ni.


Invertir en oro said...

thanks for this infor, i would like to read more about this topic.