Search code examples
pythondjangobuildoutdjango-lfs

Install package in buildout environment


I'm using django-lfs that i installed it using buildout. Now i need to install some other packages to my development environment.

My question is: What is the best way to install other packages (not system wide) in this kind of environment.
Say i want to install django-debug-toolbar only on my dev environment, but not in production.

I'm a user of virtualenv and pip

My project structure

myproject/
  README.txt  
  bootstrap.py  
  develop-eggs/  
  eggs/         
  misc/   
  scripts/
  bin/        
  buildout.cfg  
  dlcache/       
  lfs_project/  
  parts/  
  setup.cfg

Solution

  • You add the packages to your buildout.cfg. Presumably there is a eggs = entry in that file, either at the global level (in the [buildout] section) or at the individual recipe level.

    Adding extra lines is easy, it should end up looking something like this:

    eggs = 
        django-lfs
        django-debug-toolbar
    

    The egg names are white-space separated, new lines that are indented count as part of the initial line that is not (standard ConfigParser format).

    To differentiate between production and development configurations, simply create separate buildout configurations; I always use a development.cfg and a production.cfg (and staging.cfg, individual cluster machine .cfgs, etc). Buildout configurations can include and override other configurations, so your development.cfg could simply include production.cfg and add eggs and/or alter settings.

    See the buildout website for more information. If you want a complex example, look at the Jarn Plone bootstrap buildout; it uses separate production.cfg and development.cfg setups.