Skip to content

Replace pkg_resources with importlib_resources#1131

Merged
m4rc1e merged 9 commits intomainfrom
pkg
Jul 23, 2025
Merged

Replace pkg_resources with importlib_resources#1131
m4rc1e merged 9 commits intomainfrom
pkg

Conversation

@m4rc1e
Copy link
Copy Markdown
Collaborator

@m4rc1e m4rc1e commented Jul 23, 2025

pkg_resources has been removed in python 3.12+.

Maybe I'm getting old but I hate this type of change. There's obviously a good reason for it but I'm just tired.

The migration guide was super handy, https://importlib-resources.readthedocs.io/en/latest/migration.html#pkg-resources-resource-filename

Comment thread Lib/gftools/scripts/push_stats.py Outdated
from gftools.push.trafficjam import PushItems
from jinja2 import Environment, FileSystemLoader, select_autoescape
from pkg_resources import resource_filename
import importlib_resources
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you meant importlib.resources with a dot in the middle, the one from the standard library:

https://docs.python.org/3/library/importlib.resources.html

importlib_resources is the backport for older pythons, you probably don't need it if you stick to the minimum common denominator of the python versions that gftools supports:

https://pypi.org/project/importlib-resources/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you really want to use the backport you should specify the dependency in the setup.py or pyproject.toml etc.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I see importlib.resources has been around since py3.7 so I'll replace.

@m4rc1e
Copy link
Copy Markdown
Collaborator Author

m4rc1e commented Jul 23, 2025

Right, off to install Py3.9

Comment thread tests/push/test_items.py Outdated
Comment thread tests/push/test_items.py
Comment thread Lib/gftools/scripts/push_stats.py Outdated
@m4rc1e m4rc1e merged commit 099307d into main Jul 23, 2025
12 checks passed
@m4rc1e m4rc1e deleted the pkg branch July 23, 2025 11:18
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.

2 participants