[Distutils] [buidout] ignoring site-packages

Martijn Faassen faassen at startifact.com
Mon Sep 14 16:28:42 CEST 2009

Hi there,

A long-standing issue with using buildout is that even though it creates 
a restricted environment, it still uses the site-packages of the system 
python and there's no way to get rid of it. This is why for instance the 
Grok project tells people to create their buildouts within a "virtualenv 
--no-site-packages" virtual env. Because if we don't, a lot of people 
(especially all Mac OS X users that don't create their own python) will 
have a failing buildout due to conflicting libraries.

The following code snippet could be added to the buildout-generated 
scripts, after the 'sys.path[:]' assignment:

import site
packages = set(sys.path)
site_packages = set()
packages = packages.difference(site_packages)
sys.path = list(packages)

This cleans all site packages out of sys.path before any further code is 

How to make sure we run without site packages? We could of course add an 
option to buildout when it's run:

$ bin/buildout --no-site-packages

Unfortunately this would mean all buildout users would need to remember 
this. It therefore seems sensible to me to also add one to buildout.cfg:

no-site-packages = true

What do people think?

See also this bug:




More information about the Distutils-SIG mailing list