pin setuptools<82 in pip packaging command to prevent pkg_resources removal #278
Merged
rory-xu merged 3 commits intoaws-cloudformation:masterfrom Apr 16, 2026
Merged
Conversation
tagaws
commented
Apr 15, 2026
| "cloudformation-cli>=0.2.26", | ||
| "types-dataclasses>=0.1.5", | ||
| "setuptools", | ||
| "setuptools<82", |
Contributor
Author
There was a problem hiding this comment.
Protects the dev env (venv) from pinning incorrect setuptools version still safe to add a <82 here, although codegen.py is what compiles it into the build: - If someone uses a different build tool or manually runs pip against requirements.txt
tagaws
commented
Apr 15, 2026
| @@ -1 +1,2 @@ | |||
| {{ support_lib_name }}>=2.1.9 | |||
| setuptools<82 | |||
Contributor
Author
There was a problem hiding this comment.
Without this change, a brand new project created with cfn init would get a requirements.txt containing only:
cloudformation-cli-python-lib>=2.1.9
You would still need to pin <82 locally to get cfn init working based on my testing on a fresh instalation without pinning <82 when you run cfn init you will get the following error "ModuleNotFoundError: No module named 'pkg_resources' "
Contributor
Author
|
Issue mentioned here aws-cloudformation/cloudformation-cli#1117 |
AkifRafique
approved these changes
Apr 16, 2026
rory-xu
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Companion to aws-cloudformation/cloudformation-cli#[https://github.com/aws-cloudformation/cloudformation-cli/pull/1118]
Problem
cfn submitruns:pip install --upgrade --requirement requirements.txt --target build/
With no setuptools version constraint,
--upgradepulls setuptools 82+ into the build zip. setuptools 82 removedpkg_resources, breakingcloudformation-cli-python-libat runtime.Downgrading setuptools in the dev venv does NOT fix this — cfn submit re-installs fresh into build/ regardless of the venv state.
Changes
codegen.py_make_pip_command: appendsetuptools<82to the pip install command so the build zip never contains a broken setuptoolssetup.py: pinsetuptools<82ininstall_requirestemplates/requirements.txt: addsetuptools<82so new projects fromcfn inithave the pin from day oneTesting
rpdk.logconfirmssetuptools-81.0.0installed during packaging (not 82+)test__make_pip_command_pins_setuptools_lt_82added tocodegen_test.pycfn submit --dry-run+ zip inspection confirms constraint works (Also tested cfn test with sam local deploy working as expected)