python: ttfautohint: Python 3.12 support
Since python 3.12, pkg_resources has been moved to setuptools. Also, it is deprecated.
- https://github.com/Kozea/Radicale/issues/1184
- https://github.com/mu-editor/mu/issues/2485
- https://github.com/python/cpython/issues/95299
$ python -m ttfautohint --help
Traceback (most recent call last):
File "/usr/lib/python3.12/site-packages/ttfautohint/_version.py", line 2, in <module>
from pkg_resources import get_distribution, DistributionNotFound
ModuleNotFoundError: No module named 'pkg_resources'
During handling of the above exception, another exception occurred:
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 "/usr/lib/python3.12/site-packages/ttfautohint/__init__.py", line 12, in <module>
from ttfautohint._version import __version__
File "/usr/lib/python3.12/site-packages/ttfautohint/_version.py", line 4, in <module>
except (ImportError, DistributionNotFound):
^^^^^^^^^^^^^^^^^^^^
NameError: name 'DistributionNotFound' is not defined
This is a good idea. I’m using it as a patch for Fedora’s new python-ttfautohint-py package. Otherwise, since pkg_resources was moved into setuptools, there’s an implicit/undeclared runtime dependency on setuptools.
I’m also running into this issue, when using FontMake with the --autohint option, on Python 3.12 or higher.
If I make this same change to my local venv/lib/python3.12/site-packages/ttfautohint/_version.py, things start to work again. Interestingly, if I instead pip install specifically from the fork, other failures happen.
@anthrotype any chance this PR is mergeable? If not, would you suggest a different approach? For now, I’m just using Python 3.11, but I’m not sure whether this is advisable in the long run.