Skip to content

[Legacy PR #45] Replaced depreciated pkg_resources with importlib.resources in precalculated_text_measurer.py for Python 3.12 support (by @ashrobertsdragon) - #21

Merged
ashrobertsdragon merged 4 commits into
masterfrom
legacy-pr-45
Jul 13, 2025

Conversation

@ashrobertsdragon

Copy link
Copy Markdown

Original Author: @ashrobertsdragon
Original PR: google#45


I had the same issue as issue google#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
ashrobertsdragon merged commit 6e137cf into master Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Legacy #44] pkg_resources is not available by default in Python 3.12

1 participant