Don't assume pkg_resources is a module.
In setuptools < 8.3 pkg_resources.py was a module, so import pkg_resources print(pkg_resources.__file__) would print something like /home/mg/src/buildout/eggs/setuptools-8.0.4-py2.7.egg/pkg_resources.py Starting from setuptools 8.3 pkg_resources became a package, so the above code prints /home/mg/src/buildout/eggs/setuptools-11.3.1-py2.7.egg/pkg_resources/__init__.py which means a single os.path.dirname() is no longer sufficient to find the location of the .egg file/directory. I'm pretty sure 'setuptools' itself was always a package, so use two os.path.dirname()s on setuptools.__file__ to find the .egg location more reliably with both old and new setuptools versions. Fixes https://github.com/buildout/buildout/issues/227
Showing with 3 additions and 2 deletions