RFE: Replace use of `pkg_resources` with `importlib.metadata`
See discussions: astropy/astropy#11091 pypa/pip#7413
[tkloczko@devel-g2v SRPMS]$ rpm -ql python-babel | grep py$ | xargs grep pkg_resources
/usr/lib/python3.8/site-packages/babel/messages/checkers.py: from pkg_resources import working_set
/usr/lib/python3.8/site-packages/babel/messages/checkers.py: # if pkg_resources is not available or no usable egg-info was found
/usr/lib/python3.8/site-packages/babel/messages/extract.py: from pkg_resources import working_set
/usr/lib/python3.8/site-packages/babel/messages/extract.py: # if pkg_resources is not available or no usable egg-info was found
In this case if babel sphinx extension is used in copy.py in some cases it casues effect described in setuptools ticket https://github.com/pypa/setuptools/issues/3279
I start to see deprecation warnings in some unit test suites:
babel/messages/checkers.py:160: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import working_set
It is really bad because pybabel essentially does not work with python 3.12 with third party extractors.
[python: **.py]
[jinja2: templates/**.html]
ValueError: Unknown extraction method 'jinja2'
With python 3.11, it works ok.
Can this be solved on Python >= 3.12 by doing pip install setuptools?
https://docs.python.org/3/whatsnew/3.12.html
gh-95299: Do not pre-install setuptools in virtual environments created with venv. This means that distutils, setuptools, pkg_resources, and easy_install will no longer available by default; to access these run pip install setuptools in the activated virtual environment.
@cclauss thank you. It works, so it is good workaround for now.
We are working on a patch to introduce fallback to importlib.metadata
I also get the error ValueError: Unknown extraction method 'jinja2'. Installing setuptools via pip install setuptools doesn't solve this problem for me. I have tried it on MacOS 15.1 with Python 3.9 and ArchLinux with Python 3.12.
Edit: I also tried to install setuptools with brew install python-setuptools (Mac) respectively sudo pacman -S python-setuptools (Linux), but that also doesn't help.
Edit 2: I have found a workaround. Instead of directly using pybabel, I now use ./venv/bin/pybabel, which is working fine. :)