-
Notifications
You must be signed in to change notification settings - Fork 38.6k
lint: replace deprecated pkg_resources with importlib.metadata #28347
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
lint: replace deprecated pkg_resources with importlib.metadata #28347
Conversation
in our python linter: ``` ./test/lint/lint-python.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html import pkg_resources ``` The importlib.metadata library was added in Python 3.8, which is currently our minimum-supported Python version. For more details about importlib.metadata, see https://docs.python.org/3/library/importlib.metadata.html
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Any idea why CI passes here, but not on #28208 (comment) ? |
Not sure. I began with that approach and it seemed to work locally, before realizing it is only supported since Python 3.10, and that its mapping for pyzmq is odd: |
This is used, see for example bitcoin/bitcoin#28347 (comment)
|
So I guess it will break if someone is running this outside of the lint docker? |
|
I tested locally by running |
|
So it works on python3.8, and 3.9, and 3.10 (or a later version)? lgtm ACK 6c008a2 (review only, did not test) |
I would expect so, as the |
|
Yes, tested locally: |
…rtlib.metadata 6c008a2 script: replace deprecated pkg_resources with importlib.metadata (Jon Atack) Pull request description: Running our python linter with a recent python and the latest release of setuptools [v68.1.2](https://setuptools.pypa.io/en/stable/history.html): ``` $ python3 --version Python 3.11.5 $ ./test/lint/lint-python.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html import pkg_resources ``` Using `pkg_resources` was [deprecated](pypa/setuptools#3843) earlier in [v67.5.0](https://setuptools.pypa.io/en/stable/history.html#id55): "Although pkg_resources has been discouraged for use, some projects still consider pkg_resources viable for usage. This change makes it clear that pkg_resources should not be used, emitting a DeprecationWarning when imported." The `importlib.metadata` library requires Python 3.8, which is currently our minimum-supported Python version. For more details about `importlib.metadata` and the two methods imported and used here, see: - https://docs.python.org/3/library/importlib.metadata.html - https://importlib-metadata.readthedocs.io/en/latest/api.html#importlib_metadata.metadata - https://importlib-metadata.readthedocs.io/en/latest/api.html#importlib_metadata.PackageNotFoundError ACKs for top commit: MarcoFalke: lgtm ACK 6c008a2 (review only, did not test) Tree-SHA512: f5258d37043fcc9744f85641a60a3395ad43822c72d030dea8c39fa7f48ec3d7790cdeeb832f96e8f38046adb7c62fbc577c975ef0c77c8047c0c8f2353ce540
Running our python linter with a recent python and the latest release of setuptools v68.1.2:
Using
pkg_resourceswas deprecated earlier in v67.5.0: "Although pkg_resources has been discouraged for use, some projects still consider pkg_resources viable for usage. This change makes it clear that pkg_resources should not be used, emitting a DeprecationWarning when imported."The
importlib.metadatalibrary requires Python 3.8, which is currently our minimum-supported Python version.For more details about
importlib.metadataand the two methods imported and used here, see: