Skip to content

Conversation

@jonatack
Copy link
Member

@jonatack jonatack commented Aug 26, 2023

Running our python linter with a recent python and the latest release of setuptools v68.1.2:

$ 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 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.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:

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
@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 26, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK MarcoFalke

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #28184 (lint: fix custom mypy cache dir setting by fjahr)

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.

@maflcko
Copy link
Member

maflcko commented Aug 27, 2023

Any idea why CI passes here, but not on #28208 (comment) ?

@fanquake fanquake changed the title script: replace deprecated pkg_resources with importlib.metadata lint: replace deprecated pkg_resources with importlib.metadata Aug 27, 2023
@jonatack
Copy link
Member Author

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: 'zmq': ['pyzmq']}.

@maflcko maflcko removed the Consensus label Aug 27, 2023
maflcko pushed a commit to maflcko/DrahtBot that referenced this pull request Aug 27, 2023
@maflcko
Copy link
Member

maflcko commented Aug 27, 2023

So I guess it will break if someone is running this outside of the lint docker?

@jonatack
Copy link
Member Author

I tested locally by running ./test/lint/lint-python.py from root after uninstalling deps, or changing their name in DEPS, without docker.

@maflcko
Copy link
Member

maflcko commented Aug 27, 2023

So it works on python3.8, and 3.9, and 3.10 (or a later version)?

lgtm ACK 6c008a2 (review only, did not test)

@maflcko maflcko added this to the 26.0 milestone Aug 27, 2023
@jonatack
Copy link
Member Author

jonatack commented Aug 27, 2023

So it works on python3.8, and 3.9, and 3.10 (or a later version)?

I would expect so, as the importlib.metadata library requires 3.8 and higher (I tested with 3.11.5).

@maflcko
Copy link
Member

maflcko commented Aug 27, 2023

Yes, tested locally:

# git log -1 --format='%H' && python --version && ./test/lint/lint-python.py 
6c008a20067eb8574f4bd94acdd1d18ff7110d91
Python 3.11.4
Success: no issues found in 271 source files


# git log -1 --format='%H' && python --version && ./test/lint/lint-python.py 
6c008a20067eb8574f4bd94acdd1d18ff7110d91
Python 3.8.17
Success: no issues found in 271 source files

@maflcko maflcko removed this from the 26.0 milestone Aug 27, 2023
@maflcko maflcko requested a review from fanquake August 29, 2023 06:59
@fanquake fanquake merged commit ab42b2e into bitcoin:master Aug 29, 2023
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Sep 8, 2023
…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
@jonatack jonatack deleted the 2023-08-replace-deprecated-pkg_resources-with-importlib branch November 2, 2023 21:23
@bitcoin bitcoin locked and limited conversation to collaborators Dec 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants