A pkg_resources to importlib.resources and importlib.metadata migration helper.
About
packagedata is a migration helper library designed to ease the transition from the deprecated pkg_resources API to the modern importlib.resources and importlib.metadata APIs.
The pkg_resources package was deprecated in setuptools 67.5.0 (05 Mar 2023) and removed on setuptools 82.0.0 (8 Feb 2026). This library provides a replacement specially tailored for maintainers of packages that fall in an impossible position of needing to support both older Python versions while migrating to the new APIs.
If you are maintaining for Python >=3.9, please use the standard library importlib.resources. If you need entry points and maintaining for Python >=3.12, please use importlib.metadata directly. If you don’t fall in those categories this library may help you migrate and maintain your code.
So, to reiterate: if you are maintaining for a modern Python version (>=3.7), this package is not for you.
Installation
pip install packagedata
The package automatically handles the installation of required backports for older Python versions:
importlib-resources for Python < 3.9
importlib-metadata for Python < 3.9
Migration Guide
Reading Text Files
Change:
from pkg_resources import resource_string
text = resource_string(__package__, 'data/README.txt').decode('utf-8')
To:
import packagedata as pkgdata
text = pkgdata.read_text(__package__, 'data/README.txt', encoding='utf-8')
Then, eventually, when you can, change it to:
from importlib import resources
text = resources.read_text(__package__, 'data/README.txt', encoding='utf-8')
Reading Binary Files
Change:
from pkg_resources import resource_string
data = resource_string(__package__, 'assets/icon.ico')
To:
import packagedata as pkgdata
data = pkgdata.read_bytes(__package__, 'assets/icon.ico')
Then, eventually, when you can, change it to:
from importlib import resources
data = resources.read_binary(__package__, 'assets/icon.ico')
Getting File Paths
Change:
import os
import os.path
from pkg_resources import resource_filename
templates_path = resource_filename(__package__, 'templates')
for filename in os.listdir(templates_path):
filepath = os.path.join(templates_path, filename)
print(filepath)
To:
import packagedata as pkgdata
with pkgdata.as_path(__package__, 'templates') as templates_path:
for filepath in templates_path.iterdir():
print(filepath)
Then, eventually, when you can, change it to:
from importlib import resources
with resources.as_file(
resources.files(__package__).joinpath('templates')
) as templates_path:
for filepath in templates_path.iterdir():
print(filepath)
Entry Points
Change:
from pkg_resources import iter_entry_points
for ep in iter_entry_points('my_entry_point_group'):
print(f"{ep.name}: {ep.module_name}:{ep.attrs}")
plugin = ep.load()
To:
import packagedata as pkgdata
for ep in pkgdata.entry_points('my_entry_point_group'):
print(f"{ep.name}: {ep.value}")
plugin = ep.load()
Then, eventually, when you can, change it to:
from importlib import metadata
for ep in metadata.entry_points().select(group='my_entry_point_group'):
print(f"{ep.name}: {ep.value}")
plugin = ep.load()
Note on compatibility:
The packagedata.entry_points() function handles API differences between Python versions:
Python 3.10+: Uses the new EntryPoints.select() method.
Python 3.7-3.9: Uses the legacy dict-like interface.
So while no “selectable” entry points are exposed, the same code works across all supported Python versions and mimics the pkg_resources behavior.
License
Copyright (C) 2025 KuraLabs S.R.L
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
Metadata
Release files for packagedata 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| packagedata-1.2.0.tar.gz | 8.4 kB | Without provenance | Details for packagedata-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| packagedata-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for packagedata-1.2.0-py3-none-any.whl |
Total release size: 17.2 kB
Release files / packagedata-1.2.0.tar.gz
| Download URL | packagedata-1.2.0.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c56fa7d9fcf4b352e969ab43ede22fbc9a196d4079a937a7c1b1f0284280c96
|
|
BLAKE2b-256 checksum How to use checksums |
273d15857e2a15fd7163ff2ae802eeb0dfc21c90327c7b0e231196a1826e01cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / packagedata-1.2.0-py3-none-any.whl
| Download URL | packagedata-1.2.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8808abf54f0a26ce5e4e08107c437b6789fe104919fb9ee13f4ccc364163f375
|
|
BLAKE2b-256 checksum How to use checksums |
00f5bc1e08ed09f7a26974f9d1646dd2e814323a8c794365f406efbad719f2a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for packagedata 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.