Skip to content

Commit

Permalink
In PathDistribution, only resolve normalized names for non-legacy (no…
Browse files Browse the repository at this point in the history
…n-egg) packages. Fixes #320.
  • Loading branch information
jaraco committed May 28, 2021
1 parent 7f2f09a commit ea72278
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v4.3.1
=======

* #320: Fix issue where normalized name for eggs was
incorrectly solicited, leading to metadata being
unavailable for eggs.

v4.3.0
=======

Expand Down
10 changes: 10 additions & 0 deletions importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,17 @@ def locate_file(self, path):

@property
def _normalized_name(self):
"""
Performance optimization: where possible, resolve the
normalized name from the file system path.
"""
stem = os.path.basename(str(self._path))
return self._name_from_stem(stem) or super()._normalized_name

def _name_from_stem(self, stem):
name, ext = os.path.splitext(stem)
if ext not in ('.dist-info', '.egg-info'):
return
name, sep, rest = stem.partition('-')
return name

Expand Down

0 comments on commit ea72278

Please sign in to comment.