Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mgedmin
Copy link
Member

@mgedmin mgedmin commented Jan 7, 2015

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 #227

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 #227
@tseaver
Copy link
Contributor

tseaver commented Jan 7, 2015

LGTM

tseaver added a commit that referenced this pull request Jan 7, 2015
@tseaver tseaver merged commit 88ad9f4 into buildout:master Jan 7, 2015
@mgedmin mgedmin deleted the pkg_resources-is-a-package-now branch January 7, 2015 17:18
tseaver added a commit that referenced this pull request Apr 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dev.py fails with recent setuptools.
2 participants