Skip to content
This repository was archived by the owner on Aug 11, 2025. It is now read-only.

Conversation

ashrobertsdragon
Copy link

I had the same issue as issue #44 pkg_resources is not available by default in Python 3.12. The library pkg_resources was removed from Python in version 3.12 and users are directed to use the resources module in importlib instead. The code is a little different because the methods resource_exists doesn't exist in importlub.resources but naming a files object and then checking to see if it exists seems to do the trick.

I have also had to update Pillow to 10.1 and requests to 2.32.3 as these are the oldest (non-yanked in the case of requests) versions that support Python 3.12. Unfortunately, these versions remove support for Python 3.7, so I also updated the minimum version to 3.8 (the python_requires line of setup.py was still set at 3.4). I also updated xmldiff to version 2.6, also the oldest version to support Python 3.12. nox passed with the xmldiff 2.4, but with warnings.

Note: as is, this version will not support Python 3.13 when it is released. nox provided the following depreciation warning:
pybadges_init_.py:33: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13

This is my first pull request aside for the one I accidentally opened on my own repo, but I've read a few others. I have read and followed the contributing guidelines and code of conduct. I have run nox on this branch. It passed all the tests it could run on my machine (type_check is not supported on Windows). I have submitted the required Contributer's License Agreement.

ashrobertsdragon added a commit to ProsePal/py-badge that referenced this pull request Jul 13, 2025
[Legacy PR google#45] Replaced depreciated pkg_resources with importlib.resources in precalculated_text_measurer.py for Python 3.12 support (by @ashrobertsdragon)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant