Skip to content

Commit

Permalink
Merge pull request #381 from python/bugfix/entry-points-unique-normal…
Browse files Browse the repository at this point in the history
…ized

Fix expectation on unique packages to include normalization.
  • Loading branch information
jaraco committed Nov 5, 2022
1 parent 648c868 commit 1f46e76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Lib/importlib/metadata/__init__.py
Expand Up @@ -938,7 +938,10 @@ def _normalized_name(self):
normalized name from the file system path.
"""
stem = os.path.basename(str(self._path))
return self._name_from_stem(stem) or super()._normalized_name
return (
pass_none(Prepared.normalize)(self._name_from_stem(stem))
or super()._normalized_name
)

@staticmethod
def _name_from_stem(stem):
Expand Down
10 changes: 6 additions & 4 deletions Lib/test/test_importlib/test_metadata_api.py
Expand Up @@ -89,13 +89,15 @@ def test_entry_points_distribution(self):
self.assertIn(ep.dist.name, ('distinfo-pkg', 'egginfo-pkg'))
self.assertEqual(ep.dist.version, "1.0.0")

def test_entry_points_unique_packages(self):
# Entry points should only be exposed for the first package
# on sys.path with a given name.
def test_entry_points_unique_packages_normalized(self):
"""
Entry points should only be exposed for the first package
on sys.path with a given name (even when normalized).
"""
alt_site_dir = self.fixtures.enter_context(fixtures.tempdir())
self.fixtures.enter_context(self.add_sys_path(alt_site_dir))
alt_pkg = {
"distinfo_pkg-1.1.0.dist-info": {
"DistInfo_pkg-1.1.0.dist-info": {
"METADATA": """
Name: distinfo-pkg
Version: 1.1.0
Expand Down

0 comments on commit 1f46e76

Please sign in to comment.