Skip to content

Commit ef0ce71

Browse files
committed
Support .egg installations
Signed-off-by: Anthony Sottile <[email protected]>
1 parent eb107b0 commit ef0ce71

File tree

6 files changed

+24
-39
lines changed

6 files changed

+24
-39
lines changed

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include *.py MANIFEST.in LICENSE README.rst
2-
global-include *.txt *.rst *.ini *.cfg *.toml *.whl
2+
global-include *.txt *.rst *.ini *.cfg *.toml *.whl *.egg
33
exclude .gitignore
44
prune build
55
prune .tox

README.rst

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,6 @@ tools (or other conforming packages). It does not support:
2626

2727
- Packages in the stdlib.
2828
- Packages installed without metadata.
29-
- Packages installed as eggs.
30-
31-
Eggs
32-
----
33-
34-
Not only does ``importlib_metadata`` not support loading metadata
35-
from eggs, it will crash when it attempts to load metadata for
36-
any package that's an egg.
37-
38-
``easy_install`` creates eggs when installing packages, which is why
39-
you should use ``pip`` to install packages. ``pip`` never installs
40-
eggs. There are some cases, however, where a project's usage
41-
may not be able to avoid ``easy_install``. In particular, if a project
42-
uses ``setup.py test``, any ``install_requires`` of that project that
43-
aren't already installed will be installed using ``easy_install``.
44-
Additionally, any project defining ``setup_requires`` may get those
45-
dependencies installed as eggs if those dependencies aren't met before
46-
setup.py is invoked (for any command).
47-
48-
Because ``importlib_metadata`` doesn't support loading metadata from
49-
eggs and because ``importlib_metadata`` calls itself to get its own version,
50-
simply importing ``importlib_metadata`` will fail if it is installed as an
51-
egg. Any package that incorporates ``importlib_metadata`` (directly
52-
or indirectly) should be prepared to guide its users to tools that avoid
53-
installing eggs (such as `pip <https://pypi.org/project/pip>`_ and
54-
`tox <https://pypi.org/project/tox>`_).
55-
56-
More detail and discussion can be found at
57-
`issue 19 <https://gitlab.com/python-devs/importlib_metadata/issues/19>`_.
58-
5929

6030
Project details
6131
===============

importlib_metadata/_hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class MetadataPathFinder(NullFinder):
5757
This finder supplies only a find_distributions() method for versions
5858
of Python that do not have a PathFinder find_distributions().
5959
"""
60-
search_template = r'{pattern}(-.*)?\.(dist|egg)-info'
60+
search_template = r'(?:{pattern}(-.*)?\.(dist|egg)-info|EGG-INFO)'
6161

6262
def find_distributions(self, name=None, path=None):
6363
"""Return an iterable of all Distribution instances capable of
1.46 KB
Binary file not shown.

importlib_metadata/tests/test_zip.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414
from contextlib2 import ExitStack
1515

1616

17-
class BespokeLoader:
18-
archive = 'bespoke'
19-
20-
2117
class TestZip(unittest.TestCase):
2218
def setUp(self):
23-
# Find the path to the example.*.whl so we can add it to the front of
19+
# Find the path to the example-*.whl so we can add it to the front of
2420
# sys.path, where we'll then try to find the metadata thereof.
2521
self.resources = ExitStack()
2622
self.addCleanup(self.resources.close)
@@ -48,3 +44,21 @@ def test_files(self):
4844
for file in files('example'):
4945
path = str(file.dist.locate_file(file))
5046
assert '.whl/' in path, path
47+
48+
49+
class TestEgg(TestZip):
50+
def setUp(self):
51+
# Find the path to the example-*.egg so we can add it to the front of
52+
# sys.path, where we'll then try to find the metadata thereof.
53+
self.resources = ExitStack()
54+
self.addCleanup(self.resources.close)
55+
egg = self.resources.enter_context(
56+
path('importlib_metadata.tests.data',
57+
'example-21.12-py3.6.egg'))
58+
sys.path.insert(0, str(egg))
59+
self.resources.callback(sys.path.pop, 0)
60+
61+
def test_files(self):
62+
for file in files('example'):
63+
path = str(file.dist.locate_file(file))
64+
assert '.egg/' in path, path

setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ packages = find:
2828
importlib_metadata =
2929
docs/*
3030
docs/_static/*
31-
importlib_metadata.tests.data03 =
32-
namespace/*
31+
importlib_metadata.tests.data =
32+
*.egg
33+
*.whl
3334

3435
[mypy]
3536
ignore_missing_imports = True

0 commit comments

Comments
 (0)