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

Replace deprecated usage of pkg_resources with importlib.resources #58

Merged
merged 2 commits into from
Mar 18, 2024
Merged

Replace deprecated usage of pkg_resources with importlib.resources #58

merged 2 commits into from
Mar 18, 2024

Conversation

calcmogul
Copy link
Contributor

@calcmogul calcmogul commented Oct 9, 2023

Fixes #66.

@calcmogul
Copy link
Contributor Author

calcmogul commented Oct 9, 2023

pkg_resources no longer exists in GitHub Actions's Ubuntu 22.04 container with Python 3.12.

From https://github.com/wpilibsuite/styleguide/actions/runs/6461655009/job/17541789753?pr=263:

 Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 148, in _get_module_details
  File "<frozen runpy>", line 112, in _get_module_details
  File "/home/runner/work/styleguide/styleguide/wpiformat/wpiformat/__init__.py", line 13, in <module>
    from wpiformat.clangtidy import ClangTidy
  File "/home/runner/work/styleguide/styleguide/wpiformat/wpiformat/clangtidy.py", line 6, in <module>
    import clang_tidy
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/clang_tidy/__init__.py", line 5, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

This is the deprecation message I got with Python 3.11 in the container:

../../../../.local/lib/python3.11/site-packages/clang_tidy/__init__.py:5
  /home/tav/.local/lib/python3.11/site-packages/clang_tidy/__init__.py:5: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

@renefritze
Copy link
Collaborator

Thanks @calcmogul for the PR. Testing the change now: https://github.com/ssciwr/clang-tidy-wheel/actions/runs/7485613763

Copy link
Collaborator

@renefritze renefritze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@calcmogul
Copy link
Contributor Author

calcmogul commented Jan 11, 2024

Looks like the new importlib API was added in Python 3.9.

https://docs.python.org/3/library/importlib.resources.html#importlib.resources.files

clang_tidy/__init__.py Outdated Show resolved Hide resolved

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@renefritze renefritze merged commit 9a4dcdf into ssciwr:main Mar 18, 2024
@calcmogul calcmogul deleted the replace-deprecated-usage-of-pkg-resources branch March 18, 2024 23:20
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.

Package doesn't run on Python 3.12
2 participants