Skip to content

Commit

Permalink
Merge pull request #379 from python/bugfix/egg-on-face
Browse files Browse the repository at this point in the history
Fix filesystem path distribution name inference parsing.
  • Loading branch information
jaraco committed Nov 5, 2022
1 parent 9963088 commit 648c868
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Lib/importlib/metadata/__init__.py
Expand Up @@ -940,11 +940,20 @@ def _normalized_name(self):
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)
@staticmethod
def _name_from_stem(stem):
"""
>>> PathDistribution._name_from_stem('foo-3.0.egg-info')
'foo'
>>> PathDistribution._name_from_stem('CherryPy-3.0.dist-info')
'CherryPy'
>>> PathDistribution._name_from_stem('face.egg-info')
'face'
"""
filename, ext = os.path.splitext(stem)
if ext not in ('.dist-info', '.egg-info'):
return
name, sep, rest = stem.partition('-')
name, sep, rest = filename.partition('-')
return name


Expand Down

0 comments on commit 648c868

Please sign in to comment.