Buildout 2 and setuptools 0.7/0.8 problems and some solutions

Tags: python, django

Distribute (which was a well-maintained fork of setuptools) is now renamed back to setuptools. So setuptools 0.7 (and now 0.8) is out. And distribute is deprecated.

But since distribute had to pretend it was really setuptools, all sorts of hacks needed to be used. And now all those hacks have to be worked around again. => problems.

I now run into buildout problems. Running bootstrap can fail:

$ python bootstrap.py
Traceback (most recent call last):
  File "/home/vagrant/tools/bin/python", line 66, in <module>
    exec(compile(__file__f.read(), __file__, "exec"))
  File "bootstrap.py", line 154, in <module>
    ws.require(requirement)
  File ".../distribute-0.6.34-py2.7.egg/pkg_resources.py", line 696, in require
    needed = self.resolve(parse_requirements(requirements))
  File ".../eggs/distribute-0.6.34-py2.7.egg/pkg_resources.py", line 598, in resolve
    raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (setuptools 0.6c11
    (/usr/lib/python2.7/dist-packages), Requirement.parse('setuptools>=0.7'))

Solution 1: fresh bootstrap

Solution is apparently to download a fresh bootstrap: http://downloads.buildout.org/2/bootstrap.py

For me, that didn’t help as a global setuptools/distribute installation was in the way.

Solution 2: update global setuptools

Apparently I really need to update my local setuptools installation. Hey, there’s a new new temporary distribute that installs the actual 0.8 setuptools for you:

$ sudo pip install -U distribute
Password:
Downloading/unpacking distribute from
https://pypi.python.org/packages/source/d/distribute/distribute-0.7.3.zip#md5=c6c59594a7b180af57af8a0cc0cf5b4a
  Downloading distribute-0.7.3.zip (145Kb): 145Kb downloaded
  Running setup.py egg_info for package distribute

Downloading/unpacking setuptools>=0.7 (from distribute)
  Downloading setuptools-0.8.tar.gz (756Kb): 756Kb downloaded
  Running setup.py egg_info for package setuptools

Installing collected packages: distribute, setuptools
  Found existing installation: distribute 0.6.28
    Uninstalling distribute:
      Successfully uninstalled distribute
  Running setup.py install for distribute

  Found existing installation: distribute 0.6.28
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 104, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/install.py", line 250, in run
    requirement_set.install(install_options, global_options)
  File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/req.py", line 1129, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/req.py", line 477, in uninstall
    config.readfp(FakeFile(dist.get_metadata_lines('entry_points.txt')))
  File "build/bdist.macosx-10.8-intel/egg/pkg_resources.py", line 1213, in get_metadata_lines
  File "build/bdist.macosx-10.8-intel/egg/pkg_resources.py", line 1205, in get_metadata
  File "build/bdist.macosx-10.8-intel/egg/pkg_resources.py", line 1270, in _get
IOError: zipimport: can not open file /Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg

Storing complete log in /Users/reinout/Library/Logs/pip.log

Oh what?? That was on OSX. Let’s try again:

...
ImportError: Entry point ('console_scripts', 'easy_install') not found

Oh hell, my entire installation got mutilated.

I saw that too on one of my ubuntu boxes:

$ sudo easy_install -U distribute
Traceback (most recent call last):
  File "/usr/local/bin/easy_install", line 9, in <module>
    load_entry_point('distribute', 'console_scripts', 'easy_install')()
  File "/usr/local/lib/python2.7/dist-packages/setuptools-0.8-py2.7.egg/pkg_resources.py", line 378, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python2.7/dist-packages/setuptools-0.8-py2.7.egg/pkg_resources.py", line 2565, in load_entry_point
    raise ImportError("Entry point %r not found" % ((group,name),))
ImportError: Entry point ('console_scripts', 'easy_install') not found

Normally I’d take that as a message that a previously-patched-and-thus-empty setuptools installation is now used. But...

Solution 3: freshly installed setuptools

What worked:

$ wget https://bitbucket.org/pypa/setuptools/raw/0.8/ez_setup.py
$ sudo /usr/bin/python ez_setup.py

This gives you a nice fresh globally installed setuptools 0.8.

Another problem: buildout development setuptools egg

Somehow some of my buildouts had a development egg link to a setuptools or distribute version. For that I had to remove the contents of the develop-eggs/ directory in my buildout.

Another problem part two: dev eggs again

I use a recipe (syseggrecipe) that makes it easier to use globally installed packages. Especially handy for numpy/scipy and geographical libraries.

It works by adding development egg links to those packages it finds. And, of course, one of those directories with one of those packages also contained an older version of setuptools:

$ python bootstrap.py
Setting socket time out to 1 seconds.
$ bin/buildout
Setting socket time out to 1 seconds.
While:
  Installing.
  Checking for upgrades.
Error: There is a version conflict.
We already have: setuptools 0.6c11
but zc.buildout 2.2.0 requires 'setuptools>=0.7

The solution here:

$ sudo rm -rf /usr/lib/python2.7/dist-packages/setuptools*

Summary of how I got it working

  • Zap setuptools and distribute in any global locations that can interfere.
  • Install setuptools 0.8 with the ez_setup method that I also showed as ‘solution 3’ above.
  • Use the latest buildout bootstrap (‘solution 1’).
blog comments powered by Disqus
 
vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):