• Marius Gedminas's avatar
    Don't assume pkg_resources is a module. · e4101a23
    Marius Gedminas authored
    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
    e4101a23
dev.py 2.59 KB