Skip to content

fix: replace pkg_resources with importlib.metadata - #2190

Open
itzzdev09 wants to merge 1 commit into
googleapis:masterfrom
itzzdev09:fix/replace-pkg-resources
Open

itzzdev09 wants to merge 1 commit into
googleapis:masterfrom
itzzdev09:fix/replace-pkg-resources

Conversation

@itzzdev09

Copy link
Copy Markdown

setuptools 82 removed pkg_resources. requirements.txt pins setuptools==83.0.0, so in an environment built from it import synthtool.__main__ fails with ModuleNotFoundError: No module named 'pkg_resources', and so does synthtool.update_check.

Both modules only used pkg_resources.get_distribution(...).version. They now use importlib.metadata.version(...), and catch importlib.metadata.PackageNotFoundError where DistributionNotFound was caught before. No new dependencies.

Added tests/test_update_check.py, which blocks pkg_resources and imports both modules and runs check_for_updates. The 3 tests fail before the change and pass after.

Run: pytest tests/test_update_check.py

setuptools 82 removed pkg_resources, and requirements.txt pins
setuptools 83, so importing synthtool.__main__ raised
ModuleNotFoundError. importlib.metadata is in the stdlib.
@itzzdev09
itzzdev09 requested review from a team as code owners November 23, 2026 05:45
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.

1 participant