Skip to content

Commit ea72278

Browse files
committed
In PathDistribution, only resolve normalized names for non-legacy (non-egg) packages. Fixes #320.
1 parent 7f2f09a commit ea72278

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGES.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v4.3.1
2+
=======
3+
4+
* #320: Fix issue where normalized name for eggs was
5+
incorrectly solicited, leading to metadata being
6+
unavailable for eggs.
7+
18
v4.3.0
29
=======
310

importlib_metadata/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,17 @@ def locate_file(self, path):
812812

813813
@property
814814
def _normalized_name(self):
815+
"""
816+
Performance optimization: where possible, resolve the
817+
normalized name from the file system path.
818+
"""
815819
stem = os.path.basename(str(self._path))
820+
return self._name_from_stem(stem) or super()._normalized_name
821+
822+
def _name_from_stem(self, stem):
823+
name, ext = os.path.splitext(stem)
824+
if ext not in ('.dist-info', '.egg-info'):
825+
return
816826
name, sep, rest = stem.partition('-')
817827
return name
818828

0 commit comments

Comments
 (0)