Workaround setuptools 8.0 bug with zc.buildout

Posted on Sat 13 December 2014 in Plone

Buildout always fetches the latest version of setuptools for bootstraping. No matter what is defined in versions.cfg. It is possible to set the version of zc.buildout when bootstraping but not the one of setuptools.

This behavior is hardcoded in

77 ez = {}
78 exec(urlopen(''
79             ).read(), ez)
80 if not options.allow_site_packages:

Unfortunately there are some incompatible changes (a bug?) in setuptools 8.0 which prevent zc.buildout from bootstraping. It fails with the following error:

tom@localhost:~/demobuildout> python2.7
Extracting in /tmp/tmp_34LbA
Now working in /tmp/tmp_34LbA/setuptools-8.0
Building a Setuptools egg in /tmp/tmpeA5PHB
Traceback (most recent call last):
  File "", line 145, in <module>
    if _final_version(distv):
  File "", line 131, in _final_version
    for part in parsed_version:
TypeError: 'Version' object is not iterable

I found a quite easy workaround to use a different version of setuptools until this issue is fixed. Setuptools 7.0 seems to work fine. Do the following:

  1. Create a directory and change to it:

    $ mkdir setuptools-workaround
    $ cd setuptools-workaround
  2. Download

    $ wget
  3. Edit and change the setuptools version to be used.:

    39 DEFAULT_VERSION = "7.0"
    40 DEFAULT_URL = ""
  4. Start a python webserver in the directory.:

    $ python -m SimpleHTTPServer

    The server does not daemonize itself. The following actions need to be done in a new terminal.

  5. Now change the line where it downloads in your file to use the patched

    77 ez = {}
    78 exec(urlopen('http://localhost:8000/'
    79             ).read(), ez)
    80 if not options.allow_site_packages:

6. You are ready to start your working buildout.
tom@linux-zoc2:~/demobuildout> python
Extracting in /tmp/tmp82Jp3m
Now working in /tmp/tmp82Jp3m/setuptools-7.0
Building a Setuptools egg in /tmp/tmpgDuB3k
Generated script '/home/tom/demobuildout/bin/buildout'.

This works for me. Hope this bug is fixed soon anyway.