Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distribution._normalized_name for .egg-info has 'egg' in it. #413

Closed
jaraco opened this issue Nov 4, 2022 · 2 comments
Closed

Distribution._normalized_name for .egg-info has 'egg' in it. #413

jaraco opened this issue Nov 4, 2022 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@jaraco
Copy link
Member

jaraco commented Nov 4, 2022

In jaraco/keyring#526 (comment), I learned that _normalized_name for .egg-info distributions is resolving to <pkg>.egg and thus is unique against the same package with .dist-info, failing the expectation that entry points for a given package are loaded only once.

@jaraco
Copy link
Member Author

jaraco commented Nov 4, 2022

I've managed to put together a test that captures the failure, but the test passes on 4.11.4, failing on 4.11.3 and earlier only:

 importlib_metadata afdb973b3e $ git diff --cached
diff --git a/tests/test_main.py b/tests/test_main.py
index 215662dd04..8583146f2a 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -121,6 +121,23 @@ class NameNormalizationTests(fixtures.OnSysPath, fixtures.SiteDir, unittest.Test
 
         assert len(after) == len(before)
 
+    def test_egg_and_dist_same(self):
+        """
+        Two distributions varying only by metadata style should resolve
+        as the same.
+        """
+        dist_info = {'storytime.dist-info': dict(METADATA='VERSION: 1.0\n')}
+        fixtures.build_files(dist_info, self.site_dir)
+        egg_info = {'storytime.egg-info': dict(METADATA='VERSION: 1.0\n')}
+        fixtures.build_files(egg_info, self.site_dir)
+        dists = [
+            dist
+            for dist in distributions()
+            if dist._normalized_name.startswith('storytime')
+        ]
+        assert len(dists) == 2
+        assert all(dist._normalized_name == 'storytime' for dist in dists)
+

@jaraco
Copy link
Member Author

jaraco commented Nov 4, 2022

Indeed, the issue is a duplicate of #377.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

1 participant