Skip to content

Commit a92fbf3

Browse files
authored
Merge pull request #379 from python/bugfix/egg-on-face
Fix filesystem path distribution name inference parsing.
2 parents c68e382 + 9deee50 commit a92fbf3

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
v4.11.4
2+
=======
3+
4+
* #377: In ``PathDistribution._name_from_stem``, avoid including
5+
parts of the extension in the result.
6+
17
v4.11.3
28
=======
39

importlib_metadata/__init__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -958,11 +958,20 @@ def _normalized_name(self):
958958
stem = os.path.basename(str(self._path))
959959
return self._name_from_stem(stem) or super()._normalized_name
960960

961-
def _name_from_stem(self, stem):
962-
name, ext = os.path.splitext(stem)
961+
@staticmethod
962+
def _name_from_stem(stem):
963+
"""
964+
>>> PathDistribution._name_from_stem('foo-3.0.egg-info')
965+
'foo'
966+
>>> PathDistribution._name_from_stem('CherryPy-3.0.dist-info')
967+
'CherryPy'
968+
>>> PathDistribution._name_from_stem('face.egg-info')
969+
'face'
970+
"""
971+
filename, ext = os.path.splitext(stem)
963972
if ext not in ('.dist-info', '.egg-info'):
964973
return
965-
name, sep, rest = stem.partition('-')
974+
name, sep, rest = filename.partition('-')
966975
return name
967976

968977

0 commit comments

Comments
 (0)