collective / collective.recipe.omelette

https://pypi.org/project/collective.recipe.omelette/
4 stars 1 forks source link

AttributeError while running buildout #7

Open hvelarde opened 6 years ago

hvelarde commented 6 years ago

Plone 4.3.15 with setuptools 26.1.1 and buildout 2.9.5:

$ bin/buildout versions:zc.recipe.egg=2.0.4
Updating _mr.developer.
Updating instance.
Updating mkdir-chameleon.
mkdir-chameleon: Running mkdir -p /home/hvelarde/example/var/chameleon-cache
rm -Rf /home/hvelarde/example/var/chameleon-cache/*
Updating zopepy.
Updating precompile.
Compiling Python files.
Compiling locale files.
Updating checkversions.
Updating createzopecoverage.
Updating i18ndude.
Installing omelette.
While:
  Installing omelette.

An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
  File "/home/hvelarde/.buildout/eggs/zc.buildout-2.9.5-py2.7.egg/zc/buildout/buildout.py", line 2123, in main
    getattr(buildout, command)(args)
  File "/home/hvelarde/.buildout/eggs/zc.buildout-2.9.5-py2.7.egg/zc/buildout/buildout.py", line 796, in install
    installed_files = self[part]._call(recipe.install)
  File "/home/hvelarde/.buildout/eggs/zc.buildout-2.9.5-py2.7.egg/zc/buildout/buildout.py", line 1553, in _call
    return f()
  File "/home/hvelarde/.buildout/eggs/collective.recipe.omelette-0.16-py2.7.egg/collective/recipe/omelette/__init__.py", line 103, in install
    for line in dist._get_metadata('namespace_packages.txt'):
  File "/home/hvelarde/.buildout/eggs/setuptools-26.1.1-py2.7.egg/pkg_resources/__init__.py", line 2522, in _get_metadata
    if self.has_metadata(name):
  File "/home/hvelarde/.buildout/eggs/setuptools-26.1.1-py2.7.egg/pkg_resources/__init__.py", line 1463, in has_metadata
    return self.egg_info and self._has(self._fn(self.egg_info, name))
  File "/home/hvelarde/.buildout/eggs/setuptools-26.1.1-py2.7.egg/pkg_resources/__init__.py", line 1823, in _has
    return zip_path in self.zipinfo or zip_path in self._index()
  File "/home/hvelarde/.buildout/eggs/setuptools-26.1.1-py2.7.egg/pkg_resources/__init__.py", line 1703, in zipinfo
    return self._zip_manifests.load(self.loader.archive)
  File "/home/hvelarde/.buildout/eggs/setuptools-26.1.1-py2.7.egg/pkg_resources/__init__.py", line 1642, in load
    path = os.path.normpath(path)
  File "/home/hvelarde/collective/buildout.python/python-2.7/lib/python2.7/posixpath.py", line 335, in normpath
    initial_slashes = path.startswith('/')
AttributeError: 'NoneType' object has no attribute 'startswith'
hvelarde commented 6 years ago

@davisagli any hints?

davisagli commented 6 years ago

I've seen this a few times recently; I think something changed about how zipped eggs are handled and omelette is not ignoring them successfully. I don't really use omelette myself these days so I haven't felt motivated to work on fixing it.

batlock666 commented 6 years ago

I can confirm that it has something to do with zipped eggs. In my case, enum34 was installed as a zipped egg in my eggs directory. Removing the egg and running the buildout again installed it as an unzipped egg, and voila, problem solved.

It should be quite easy to fix the problem in code. There are two calls to dist._get_metadata that return a generator. Iterating over this generator throws the exception. Wrapping this in a try-except statement and returning an empty lis in case of an exception worked for me.