Use importlib.metadata instead of deprecated pkg_resources - #500
Merged
Merged
Conversation
pkg_resources is deprecated upstream and does not handle modern .dist-info directories correctly. Specifically it does not honor the new replacement rules as defined in [1]. As a result, it can't find some of cheroot's dependencies on modern Gentoo systems and ultimately fails to load with a DistributionNotFound error [2]. pkg_resources is only used to get the cheroot version and can easily be replaced with importlib.metadata [3], the intended replacement for this specific use-case. For python versions before 3.8, attempt to use the importlib_metadata backport instead. [1] https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode [2] https://bugs.gentoo.org/834522 [3] https://docs.python.org/3/library/importlib.metadata.html Thanks-to: Michał Górny <mgorny@gentoo.org> Signed-off-by: Wolfgang Müller <wolf@oriole.systems>
Author
|
Let me know what to do about the nested try block, flake8 didn't trigger on my local run of pre-commit. |
Codecov Report
@@ Coverage Diff @@
## main #500 +/- ##
==========================================
- Coverage 80.56% 79.33% -1.23%
==========================================
Files 28 28
Lines 4409 4409
==========================================
- Hits 3552 3498 -54
- Misses 857 911 +54 |
jaraco
approved these changes
Jun 22, 2022
jaraco
left a comment
Member
There was a problem hiding this comment.
I've started recommending against supplying a __version__ at all and instead directing consumers to query for importlib.metadata.version("cheroot") if they want to know the version. However, for compatibility, it's probably better to go with this approach for now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pkg_resources is deprecated upstream and does not handle modern .dist-info directories correctly. Specifically it does not honor the new replacement rules. As a result, it can't find some of cheroot's dependencies on modern Gentoo systems and ultimately fails to load with a DistributionNotFound error.
pkg_resources is only used to get the cheroot version and can easily be replaced with importlib.metadata, the intended replacement for this specific use-case. For python versions before 3.8, attempt to use the importlib_metadata backport instead.
❓ What kind of change does this PR introduce?
📋 Contribution checklist:
I do not know how to add tests for this specific failure case, so I omitted them.
the changes have been approved
and description in grammatically correct, complete sentences
This change is