lint: replace deprecated pkg_resources with importlib.metadata #28347

pull jonatack wants to merge 1 commits into bitcoin:master from jonatack:2023-08-replace-deprecated-pkg_resources-with-importlib changing 1 files +6 −4
  1. jonatack commented at 10:44 PM on August 26, 2023: member

    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:

  2. script: replace deprecated pkg_resources with importlib.metadata
    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
    6c008a2006
  3. DrahtBot commented at 10:44 PM on August 26, 2023: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--021abf342d371248e50ceaed478a90ca-->

    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.

    <!--174a7506f384e20aa4161008e828411d-->

    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.

  4. DrahtBot added the label Consensus on Aug 26, 2023
  5. maflcko commented at 6:54 AM on August 27, 2023: member

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

  6. fanquake renamed this:
    script: replace deprecated pkg_resources with importlib.metadata
    lint: replace deprecated pkg_resources with importlib.metadata
    on Aug 27, 2023
  7. jonatack commented at 1:02 PM on August 27, 2023: member

    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']}.

  8. maflcko removed the label Consensus on Aug 27, 2023
  9. maflcko referenced this in commit 93d907b749 on Aug 27, 2023
  10. maflcko commented at 1:08 PM on August 27, 2023: member

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

  11. maflcko added the label Waiting for author on Aug 27, 2023
  12. maflcko removed the label Waiting for author on Aug 27, 2023
  13. DrahtBot added the label Tests on Aug 27, 2023
  14. jonatack commented at 1:12 PM on August 27, 2023: member

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

  15. maflcko commented at 1:27 PM on August 27, 2023: member

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

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

  16. maflcko added this to the milestone 26.0 on Aug 27, 2023
  17. jonatack commented at 1:52 PM on August 27, 2023: member

    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).

  18. maflcko commented at 2:45 PM on August 27, 2023: member

    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
    
  19. maflcko removed this from the milestone 26.0 on Aug 27, 2023
  20. maflcko requested review from fanquake on Aug 29, 2023
  21. fanquake merged this on Aug 29, 2023
  22. fanquake closed this on Aug 29, 2023

  23. Frank-GER referenced this in commit db630b9e7a on Sep 8, 2023
  24. jonatack deleted the branch on Nov 2, 2023
  25. bitcoin locked this on Dec 5, 2024


fanquake

Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 21:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me