fralau / mkdocs-macros-plugin

Create richer and more beautiful pages in MkDocs, by using variables and calls to macros in the markdown code.
https://mkdocs-macros-plugin.readthedocs.io
Other
318 stars 50 forks source link

Deprecation Warning: pkg_resources #157

Closed niklasfink closed 1 year ago

niklasfink commented 1 year ago

When serving/building mkdocs with the macros plugin enabled:

INFO - DeprecationWarning: pkg_resources is deprecated as an API File "/usr/local/python/3.11.2/lib/python3.11/site-packages/mkdocs_macros/context.py", line 19, in import pkg_resources File "/usr/local/python/3.11.2/lib/python3.11/site-packages/pkg_resources/init.py", line 121, in warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)

fralau commented 1 year ago

This might be an issue with python 3.11? 🤔

johnthagen commented 1 year ago

I'm getting this warning even on Python 3.10

nox > mkdocs serve
INFO     -  DeprecationWarning: pkg_resources is deprecated as an API
              File "lib/python3.10/site-packages/mkdocs_macros/context.py", line 19, in <module>
                import pkg_resources
              File "lib/python3.10/site-packages/pkg_resources/__init__.py", line 121, in <module>
                warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)

Environment

mkdocs                     1.4.2
mkdocs-htmlproofer-plugin  0.13.1
mkdocs-macros-plugin       0.7.0
mkdocs-material            9.1.7
mkdocs-material-extensions 1.1.1
mkdocs-video               1.5.0
johnthagen commented 1 year ago

Here are some upstream information about pkg_resources as a whole being deprecated:

This module is deprecated. Users are directed to
`importlib.resources <https://docs.python.org/3/library/importlib.resources.html>`_
and
`importlib.metadata <https://docs.python.org/3/library/importlib.metadata.html>`_
instead.
johnthagen commented 1 year ago

The replacements in the standard library:

Given that Python 3.7 is end of life in just two months I would recommend bumping the minimum supported Python to 3.8 here:

https://github.com/fralau/mkdocs_macros_plugin/blob/e8e0356a2983c1f0604a4fba021c718e80cc011d/setup.py#L43

And then replace usages of pkg_resources with importlib from the standard library.

fralau commented 1 year ago

This warning should be solved, and minimal version of Python has been bumped to 3.8. Could you please test if that works for you?

(that will also be an opportunity to test if version 1.1.0-alpha works for the rest)

johnthagen commented 1 year ago

@fralau I installed the latest master branch into my Poetry environment with:

python -m pip install git+https://github.com/fralau/mkdocs_macros_plugin.git
$ python -m pip list | grep mkdocs
mkdocs                     1.4.2
mkdocs-htmlproofer-plugin  0.13.1
mkdocs-macros-plugin       1.0.0a0
mkdocs-material            9.1.7
mkdocs-material-extensions 1.1.1
mkdocs-video               1.5.0

Everything seemed to work, and I did not see any deprecation warnings printed. 🎉

fralau commented 1 year ago

@johnthagen This is excellent!