Skip to content

Commit d5f1213

Browse files
committed
Merge branch 'main' into feature/uniform
2 parents d35504d + ea72278 commit d5f1213

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

CHANGES.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ v4.4.0
33

44
* Remove SelectableGroups deprecation exception for flake8.
55

6+
v4.3.1
7+
=======
8+
9+
* #320: Fix issue where normalized name for eggs was
10+
incorrectly solicited, leading to metadata being
11+
unavailable for eggs.
12+
613
v4.3.0
714
=======
815

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ were contributed to different versions in the standard library:
4040

4141
* - importlib_metadata
4242
- stdlib
43-
* - 3.10
43+
* - 4.2
4444
- 3.10
4545
* - 1.4
4646
- 3.8

importlib_metadata/__init__.py

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

805805
@property
806806
def _normalized_name(self):
807+
"""
808+
Performance optimization: where possible, resolve the
809+
normalized name from the file system path.
810+
"""
807811
stem = os.path.basename(str(self._path))
812+
return self._name_from_stem(stem) or super()._normalized_name
813+
814+
def _name_from_stem(self, stem):
815+
name, ext = os.path.splitext(stem)
816+
if ext not in ('.dist-info', '.egg-info'):
817+
return
808818
name, sep, rest = stem.partition('-')
809819
return name
810820

tests/test_zip.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,7 @@ def test_files(self):
7979
for file in files('example'):
8080
path = str(file.dist.locate_file(file))
8181
assert '.egg/' in path, path
82+
83+
def test_normalized_name(self):
84+
dist = distribution('example')
85+
assert dist._normalized_name == 'example'

0 commit comments

Comments
 (0)