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

Felix Schwarz felix.schwarz at oss.schwarz.eu
Sat Apr 7 00:16:35 CEST 2012


Am 06.04.2012 12:45, schrieb Felix Schwarz:
> Also I should mention that the problem is somehow connected to the way how
> Fedora installs the decoratortools.
> 
> If I install 'decoratortools' manually through easy_install (system-wide), the
> problem does not appear.

Actually I understood why that's happening:
pkg_resources will activate all namespace packages on sys.path. And Fedora
puts the decoratortools in 'site-packages/peak/...' so it is found while
easy_install stores the code in 'site-packages/DecoratorTools-1.8-py2.7.egg/'.


I think I also know now why peak.utils triggers the problem. Here's the code
from pkg_resources.py

def declare_namespace(packageName):
...
path, parent = sys.path, None
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)

All other namespace packages on my system (not many) just used a simple
namespace package like 'logilab' or 'paste'. Therefore the extra
  if '.' in packageName:
code path is not executed.

And that path expects that the parent is actually loaded in sys.modules which
is not valid in zc.buildout (as it manually resets 'sys.path' after loading
site.py).

Suggestions how the problem can be fixed? I think buildout is currently broken
for nested namespace packages directly installed in site-packages.
fs



More information about the Distutils-SIG mailing list