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

[3.10] Package names with different metadata types aren't deduplicated #99130

Closed
jaraco opened this issue Nov 5, 2022 · 6 comments
Closed

[3.10] Package names with different metadata types aren't deduplicated #99130

jaraco opened this issue Nov 5, 2022 · 6 comments
Assignees
Labels
topic-importlib type-bug An unexpected behavior, bug, or error

Comments

@jaraco
Copy link
Member

jaraco commented Nov 5, 2022

In python/importlib_metadata#377, Benoit reports that the "_normalized_name" of importlib_metadata and importlib.metadata is including an extraneous .egg. This issue means that in environments where both .dist-info and .egg-info exist for a package, they're not deduplicated and the entry points are returned for both. The scenario is common and problemmatic as evidenced by other bug reports (python/importlib_metadata#410, python/importlib_metadata#413). The fix, added in importlib_metadata 4.11.4, has been ported to Python 3.11.1 in #98875, but the fix should also be backported to Python 3.10.

@jaraco jaraco added the type-bug An unexpected behavior, bug, or error label Nov 5, 2022
@jaraco
Copy link
Member Author

jaraco commented Nov 5, 2022

According to the compatibility matrix, Python 3.10 was synced at importlib_metadata 4.4. I'll confirm that's the case and then plan to backport the fix to importlib_metadata 4.4.x.

@jaraco
Copy link
Member Author

jaraco commented Nov 5, 2022

I can see in GH-31854, Python 3.10 got synced with importlib_metadata 4.11.3, so that should make the fix easier.

@jaraco
Copy link
Member Author

jaraco commented Nov 5, 2022

I can see in GH-31854, Python 3.10 got synced with importlib_metadata 4.11.3, so that should make the fix easier.

It's not that simple. Some bugfixes were backported, but other changes from importlib_metadata 4.5-4.11 were not, so there's no place on the importlib_metadata cpython branch that corresponds to what's in CPython 3.10.

This complicated scenario is a consequence of CPython's branching strategy, which only allows for squash merges (so it's not possible to merge importlib_metadata into cpython) and only allows for manual backports (no relation between the history in version branches and main).

@jaraco jaraco self-assigned this Nov 5, 2022
@jaraco
Copy link
Member Author

jaraco commented Nov 5, 2022

It looks like python/importlib_metadata@ba30e9b corresponds most closely to where CPython 3.10 was synced. To that commit I've applied the other bugfixes as found in CPython 3.10.8 as python/importlib_metadata@996308821b. Against that commit, I'm applying the changes from the merge requests that comprised 4.11.4:

 importlib_metadata maint/cpython/3.10 $ git cherry-pick -m 1 a92fbf3f500d98fbc419157a67d37608f92ea944
CONFLICT (modify/delete): CHANGES.rst deleted in HEAD and modified in a92fbf3f50 (Merge pull request #379 from python/bugfix/egg-on-face).  Version a92fbf3f50 (Merge pull request #379 from python/bugfix/egg-on-face) of CHANGES.rst left in tree.
Auto-merging Lib/importlib/metadata/__init__.py
error: could not apply a92fbf3f50... Merge pull request #379 from python/bugfix/egg-on-face
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
 importlib_metadata maint/cpython/3.10 $ git mergetool
Merging:
CHANGES.rst

Deleted merge conflict for 'CHANGES.rst':
  {local}: deleted
  {remote}: modified file
Use (m)odified or (d)eleted file, or (a)bort? d
 importlib_metadata maint/cpython/3.10 $ git cherry-pick --continue
[maint/cpython/3.10 648c868e2b] Merge pull request #379 from python/bugfix/egg-on-face
 Date: Sat May 21 11:02:35 2022 -0400
 1 file changed, 12 insertions(+), 3 deletions(-)
 importlib_metadata maint/cpython/3.10 $ git cherry-pick -m 1 2ee86fc0c4607fe1e506b91d12375fd7f32aa86a
CONFLICT (modify/delete): CHANGES.rst deleted in HEAD and modified in 2ee86fc0c4 (Merge pull request #381 from python/bugfix/entry-points-unique-normalized).  Version 2ee86fc0c4 (Merge pull request #381 from python/bugfix/entry-points-unique-normalized) of CHANGES.rst left in tree.
Auto-merging Lib/importlib/metadata/__init__.py
Auto-merging Lib/test/test_importlib/test_metadata_api.py
CONFLICT (content): Merge conflict in Lib/test/test_importlib/test_metadata_api.py
error: could not apply 2ee86fc0c4... Merge pull request #381 from python/bugfix/entry-points-unique-normalized
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
 importlib_metadata maint/cpython/3.10 $ git mergetool
Merging:
CHANGES.rst
Lib/test/test_importlib/test_metadata_api.py

Deleted merge conflict for 'CHANGES.rst':
  {local}: deleted
  {remote}: modified file
Use (m)odified or (d)eleted file, or (a)bort? d

Normal merge conflict for 'Lib/test/test_importlib/test_metadata_api.py':
  {local}: modified file
  {remote}: modified file
 importlib_metadata maint/cpython/3.10 $ git cherry-pick --continue
[maint/cpython/3.10 1f46e76d95] Merge pull request #381 from python/bugfix/entry-points-unique-normalized
 Date: Sat May 21 11:42:38 2022 -0400
 2 files changed, 10 insertions(+), 5 deletions(-)

@jaraco
Copy link
Member Author

jaraco commented Nov 5, 2022

Drat. Looks like the second cherry-pick is dependent on python/importlib_metadata@1e19fd2.

@ambv
Copy link
Contributor

ambv commented Nov 10, 2022

Thanks for finding this, @jaraco. I merged it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-importlib type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants