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

use importlib_metadata instead of importlib.metadata for python<3.10 #2304

Closed
wants to merge 1 commit into from

Conversation

mboisson
Copy link

Thanks for contributing, make sure you address all the checklists (for details on how see

development documentation)!

This PR is pretty minimal and is meant to address #2303
importlib.metadata does not provide unique results for entry_points when duplicate packages are found until python >= 3.10. To allow local installation of virtualenv to superseed global installations, we need to use importlib_metadata instead.

  • ran the linter to address style issues (tox -e fix_lint)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

@gaborbernat
Copy link
Contributor

Can we find out why using the native importlib.metadata does not work?

@mboisson
Copy link
Author

mboisson commented Feb 16, 2022

Can we find out why using the native importlib.metadata does not work?

That is explained in issue #2303, but here is a extract from the issue:

I believe this issue is caused by the switch from importlib_metadata to importlib.metadata in PR #2246

In importlib_metadata's version of entry_points, there is a step to make the imported entry points unique:
https://github.com/python/importlib_metadata/blob/main/importlib_metadata/__init__.py#L995

This ensures that only the highest priority entry_points.txt from virtualenv*.dist_info is considered.

This is also the case in importlib.metadata's latest version:
https://github.com/python/cpython/blob/main/Lib/importlib/metadata/__init__.py

but it was not the case in:
Python 3.8: https://github.com/python/cpython/blob/3.8/Lib/importlib/metadata.py#L541
Python 3.9: https://github.com/python/cpython/blob/3.9/Lib/importlib/metadata.py#L569
It was not until Python 3.10 that this was taken up:
https://github.com/python/cpython/blob/3.10/Lib/importlib/metadata/__init__.py#L978

I believe importlib_metadata should be used for Python < 3.10.

@gaborbernat
Copy link
Contributor

Closing per #2303 (comment) Please consider using instead https://pypa.github.io/pipx via https://pypi.org/project/pipx-in-pipx/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants