Skip to content

Removing pkg_resources dependency - #3833

Open
Estartu wants to merge 2 commits into
Pylons:mainfrom
Estartu:main
Open

Estartu wants to merge 2 commits into
Pylons:mainfrom
Estartu:main

Conversation

@Estartu

@Estartu Estartu commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

pkg_resources is gone for nearly a year now. There are three new releases of Setuptools and pyramid is stuck with 80.

I am not that deep in the code to really remove the dependency myself. But there are AI out there who should. So I asked Junie, the AI of Jetbrains PyCharms to do the deed and here is what it produced. It might not include all edge cases, but it could provide a start.

Here is the Summery the AI produced.

Replaced the deprecated pkg_resources usage with modern standard library alternatives (importlib.resources and importlib.metadata).
Changes
• Replaced pkg_resources in src/pyramid/path.py by implementing PackageAssetDescriptor backed by importlib.resources.files() and updating package_path() to use importlib.resources.
• Updated src/pyramid/asset.py to use PackageAssetDescriptor for abspath_from_asset_spec() instead of pkg_resources.resource_filename().
• Updated src/pyramid/static.py to use PackageAssetDescriptor for checking directory existence and locating resource paths without importing pkg_resources.
• Updated src/pyramid/config/assets.py so PackageAssetSource and _DefaultProvider delegate to PackageAssetDescriptor / importlib.resources, making pkg_resources optional and avoiding its deprecated import during runtime.
• Updated tests/test_docs.py to use importlib.metadata and updated tests/test_path.py to test PackageAssetDescriptor functionality.

Verification
• Ran the full test suite (./venv/bin/pytest) with all 2,652 tests passing.
• Verified with ./venv/bin/python -W error::UserWarning that importing and initializing Pyramid modules and Configurator produces no deprecation warnings.

Please check the code as it's mostly AI generated. Don't trust them :-)

@robvdl

robvdl commented Nov 8, 2026 via email

Copy link
Copy Markdown
Contributor

@Estartu

Estartu commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

It would be nice when the checks would report what's wrong instead of just error. How can I start the lint in a local installation.
BTW the coverage failed in the base revision,

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