Skip to content

replace pkg_resources with importlib.resources/metadata for setuptools 82 compat #1118

Merged
rory-xu merged 5 commits intoaws-cloudformation:masterfrom
tagtestorg:fix/remove-pkg-resources-setuptools82
Apr 20, 2026
Merged

replace pkg_resources with importlib.resources/metadata for setuptools 82 compat #1118
rory-xu merged 5 commits intoaws-cloudformation:masterfrom
tagtestorg:fix/remove-pkg-resources-setuptools82

Conversation

@tagaws
Copy link
Copy Markdown
Contributor

@tagaws tagaws commented Apr 15, 2026

setuptools 82.0.0 removed pkg_resources (see
https://setuptools.pypa.io/en/latest/history.html#v82-0-0).
This caused ModuleNotFoundError: No module named 'pkg_resources' on any cfn command.

Changes

  • data_loaders.py: replace pkg_resources.resource_stream with importlib.resources.files (stdlib 3.9+, with importlib_resources backport for <3.9)
  • plugin_registry.py: replace pkg_resources.iter_entry_points with importlib.metadata.entry_points
  • setup.py: add importlib_resources>=5.0 as conditional dep for Python <3.9
  • Updated unit tests and added tests/functional_importlib_compat.py integration tests

Testing

Related

  • Another PR needed in cloudformation-cli-python-plugin to pin setuptools<82 in _make_pip_command(A fix in codegen.py is needed to pin <82 as the build overides this)

@tagaws tagaws marked this pull request as ready for review April 16, 2026 09:34
@tagaws
Copy link
Copy Markdown
Contributor Author

tagaws commented Apr 16, 2026

#1117

@rory-xu rory-xu requested review from AkifRafique and rory-xu April 19, 2026 17:10
@rory-xu rory-xu merged commit 698c385 into aws-cloudformation:master Apr 20, 2026
12 checks passed
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.

3 participants