Skip to content

Commit 336eea1

Browse files
committed
fix: pin setuptools<82 to prevent pkg_resources removal breaking contract tests
1 parent 8c1494e commit 336eea1

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

python/rpdk/python/codegen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ def _make_pip_command(base_path):
322322
str(base_path / "requirements.txt"),
323323
"--target",
324324
str(base_path / "build"),
325+
"setuptools<82",
325326
]
326327

327328
@staticmethod
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
{{ support_lib_name }}>=2.1.9
2+
setuptools<82

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def find_version(*file_paths):
4040
install_requires=[
4141
"cloudformation-cli>=0.2.26",
4242
"types-dataclasses>=0.1.5",
43-
"setuptools",
43+
"setuptools<82",
4444
],
4545
entry_points={
4646
"rpdk.v1.languages": [

tests/plugin/codegen_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,17 @@ def test__build_pip(plugin):
553553
mock_pip.assert_called_once_with(sentinel.base_path)
554554

555555

556+
def test__make_pip_command_pins_setuptools_lt_82(tmp_path):
557+
"""setuptools<82 must be in the pip command to prevent pkg_resources removal."""
558+
cmd = PythonLanguagePlugin._make_pip_command(tmp_path)
559+
assert "setuptools<82" in cmd, (
560+
"setuptools<82 must be pinned in pip command — setuptools 82+ removes "
561+
"pkg_resources which breaks cloudformation-cli-python-lib at runtime"
562+
)
563+
assert str(tmp_path / "requirements.txt") in cmd
564+
assert str(tmp_path / "build") in cmd
565+
566+
556567
def test__build_pip_posix(plugin):
557568
patch_os_name = patch("rpdk.python.codegen.os.name", "posix")
558569
patch_subproc = patch("rpdk.python.codegen.subprocess_run")

0 commit comments

Comments
 (0)