[Distutils] zc.buildout: KeyError during "buildout init" with distribute 0.6.25

Felix Schwarz felix.schwarz at oss.schwarz.eu
Fri Apr 6 12:04:55 CEST 2012


Hey,

I use Python 2.7 (Fedora 16). However zc.buildout (1.5.2) does not work for me:
$ buildout init
Creating '/home/fs/temp/buildout.cfg'.
Creating directory '/home/fs/temp/bin'.
Creating directory '/home/fs/temp/parts'.
Creating directory '/home/fs/temp/eggs'.
Creating directory '/home/fs/temp/develop-eggs'.
Getting distribution for 'distribute'.
Traceback (most recent call last):
...
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2230, in activate
    map(declare_namespace, self._get_metadata('namespace_packages.txt'))
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1815, in
declare_namespace
    path = sys.modules[parent].__path__
KeyError: 'peak'
An error occurred when trying to install distribute 0.6.25. Look above this
message for any errors that were output by easy_install.
While:
  Bootstrapping.
  Getting distribution for 'distribute'.
Error: Couldn't install: distribute 0.6.25


The code which causes the exception is:
def declare_namespace(packageName):
...
        if '.' in packageName:
            parent = '.'.join(packageName.split('.')[:-1])
            declare_namespace(parent)
            if parent not in _namespace_packages:
                __import__(parent)
            try:
                path = sys.modules[parent].__path__
            except AttributeError:
                raise TypeError("Not a package:", parent)

The package which triggers the bug is 'decoratortools' (python package
'peak.utils'). If I install other namespace packages (e.g. zope.interface)
everything works fine.

The error happens because 'peak' is not in sys.modules when buildout calls
it's easy_install implementation. If I add some code to ignore the keyerror,
everything works as expected though I'm not sure that this is the right fix.

Any idea how I can fix this? Pointers welcome.
fs


More information about the Distutils-SIG mailing list