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

pkg_resources is deprecated #148

Closed
mrharpo opened this issue Apr 1, 2023 · 3 comments
Closed

pkg_resources is deprecated #148

mrharpo opened this issue Apr 1, 2023 · 3 comments

Comments

@mrharpo
Copy link

mrharpo commented Apr 1, 2023

First off, thanks for this great tool! I use it in my personal and professional projects as much as I can!

Summary

In migrating one of our projects to a PEP 621 compliant pyproject.toml, I noticed we get the following error locally and running on github actions:

Configuration and Logs

When running mike deploy:

Run pdm run mike deploy --push --update-aliases ${VERSION_TITLE%\[latest\]} latest
Traceback (most recent call last):
  File "/home/runner/work/otto/otto/.venv/bin/mike", line 5, in <module>
    from mike.driver import main
  File "/home/runner/work/otto/otto/.venv/lib/python3.11/site-packages/mike/driver.py", line 4, in <module>
    from . import arguments, commands
  File "/home/runner/work/otto/otto/.venv/lib/python3.11/site-packages/mike/commands.py", line 6, in <module>
    from pkg_resources import resource_stream
ModuleNotFoundError: No module named 'pkg_resources'
Error: Process completed with exit code 1.

I can fix that error by adding "setuptools" to our package's docs section in the optional-extras, and it generates the docs successfully, but also gives this warning:

Run pdm run mike deploy --push --update-aliases ${VERSION_TITLE%\[latest\]} latest
INFO     -  DeprecationWarning: pkg_resources is deprecated as an API
  File "/home/runner/work/otto/otto/.venv/lib/python3.11/site-packages/mike/mkdocs_plugin.py", line 6, in <module>
    from pkg_resources import iter_entry_points
  File "/home/runner/work/otto/otto/.venv/lib/python3.11/site-packages/pkg_resources/__init__.py", line 121, in <module>
    warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)

INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /home/runner/work/otto/otto/site
WARNING  -  griffe: otto/main.py:[23](https://github.com/quaternionmedia/otto/actions/runs/4584409004/jobs/8095873820#step:7:24): Empty parameters section at line 4
INFO     -  Documentation built in 0.72 seconds

Steps to Reproduce

  1. Run mike deploy
    • with setuptools == 67.6.1
  2. See DeprecationWarning

Expected Behavior

There should be no extra dependencies to install, and no warnings on deploy

Additional Context

From setuptools/docs/pkg_resources:

Use of pkg_resources is deprecated in favor of importlib.resources, importlib.metadata and their backports (importlib_resources, importlib_metadata). Users should refrain from new usage of pkg_resources and should work to port to importlib-based solutions.

@jimporter
Copy link
Owner

Thanks. As you noted, it looks like importlib is the way to go for the future here. Fixed in 063c93e.

@mrharpo
Copy link
Author

mrharpo commented Apr 2, 2023

Thanks! Works great!

@jnussbaum
Copy link

@jimporter Thanks for fixing this. Me too, I get this warning and I'm looking for a way to get rid of it. Now that I see that this is fixed, I wonder when the next release will take place?

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

No branches or pull requests

3 participants