jimporter / mike

Manage multiple versions of your MkDocs-powered documentation via Git
BSD 3-Clause "New" or "Revised" License
528 stars 47 forks source link

`pkg_resources` is deprecated #148

Closed mrharpo closed 1 year ago

mrharpo commented 1 year ago

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 commented 1 year ago

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

mrharpo commented 1 year ago

Thanks! Works great!

jnussbaum commented 1 year ago

@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?