Uh oh!
There was an error while loading. Please reload this page.
pin setuptools<82 in pip packaging command to prevent pkg_resources removal - #278
Conversation
| "cloudformation-cli>=0.2.26", | ||
| "types-dataclasses>=0.1.5", | ||
| "setuptools", | ||
| "setuptools<82", |
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
| @@ -1 +1,2 @@ | |||
| {{ support_lib_name }}>=2.1.9 | |||
| setuptools<82 | |||
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' "
tagaws
commented
Apr 16, 2026
Issue mentioned here aws-cloudformation/cloudformation-cli#1117 |
Uh oh!
There was an error while loading. Please reload this page.
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)