add an option to exclude site-packages

Bug #429383 reported by Martijn Faassen
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Buildout
New
Undecided
Unassigned

Bug Description

We need an option in buildout that can be used to run the buildout without including site-packages.

With the Grok project we now advise people to create the buildouts inside a virtualenv which is installed with --no-site-packages. This to avoid the frequent problem that Python library installed by the platform conflicts with a Python library that Grok itself wants to install. On Mac OS X in particular this problem is guaranteed.

This complicates the installation instructions significantly. buildout is so close: buildout is all about controlling the environment, but always pulls in site-packages, an uncontrolled area.

Revision history for this message
Martijn Faassen (faassen) wrote :

One possible implementation strategy would be to add the following to the generated scripts,
after the sys.path assignment:

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

What this does is add the site packages according to the 'site' module, and then remove them from the path again.

We could make it an option in buildout.cfg or an option to bin/buildout. The problem with doing this to bin/buildout means that people could accidentally add site-packages again when they re-run buildout. Since this is a problem that especially beginners run into, this seems rather risky. Or we could do both.

Revision history for this message
Jim Fulton (jim-zope) wrote : Re: [Bug 429383] [NEW] add an option to exclude site-packages

Gary Poster already implemented this. His branch is waiting for my
review. Unfortunately, his branch is rather large, so it is going to
take me a while to get to this. I'm not going to make any other
buildout changes until his branch is merged.

Jim

On Mon, Sep 14, 2009 at 9:37 AM, Martijn Faassen <email address hidden> wrote:
> Public bug reported:
>
> We need an option in buildout that can be used to run the buildout
> without including site-packages.
>
> With the Grok project we now advise people to create the buildouts
> inside a virtualenv which is installed with --no-site-packages. This to
> avoid the frequent problem that Python library installed by the platform
> conflicts with a Python library that Grok itself wants to install. On
> Mac OS X in particular this problem is guaranteed.
>
> This complicates the installation instructions significantly. buildout
> is so close: buildout is all about controlling the environment, but
> always pulls in site-packages, an uncontrolled area.
>
> ** Affects: zc.buildout
>     Importance: Undecided
>         Status: New
>
> --
> add an option to exclude site-packages
> https://bugs.launchpad.net/bugs/429383
> You received this bug notification because you are subscribed to
> Buildout.
>

--
Jim Fulton

Revision history for this message
Sridhar Ratnakumar (srid) wrote :
Revision history for this message
Sridhar Ratnakumar (srid) wrote :

To workaround this issue:

  $ mv ..../site-packages ..../site-packages.oow
  $ bin/buildout
  $ mv ..../site-packages.oow ..../site-packages

Revision history for this message
attilaolah (attilaolah) wrote :

I'm using a workaround that looks like this:

[foofix]
recipe = iw.recipe.cmd:py
on_install = true
on_update = true
cmds =
    >>> import os, re
    >>> django = os.path.join('${buildout:directory}', 'bin', 'foo')
    >>> file = open(django, 'r')
    >>> lines = list(file.readlines())
    >>> file.close()
    >>> file = open(django, 'wb')
    >>> for line in lines:
    ... if not re.match("^\W+'(.*?)%ssite-packages',$" % os.path.sep, line):
    ... file.write(line)
    >>> file.close()

where "foo" is the script I'm stripping site-packages from. This is rather ugly though.

Do you have any plan on when is this going to be fixed? Will it get in one of the 1.5.x versions, or is this postponed to 2.0? Is there anything I can do to help you speed up the process?

Revision history for this message
attilaolah (attilaolah) wrote :

As of version 1.5.0, this bug no longer affects me. It could probably be marked as "fixed".

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.