aws-cloudformation / aws-cloudformation/cloudformation-cli

`setuptools` 82.0.0 does not contain `pkg_resources` anymore

Open
#1,117 1 comment 6 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
336
Forks
172
Avg merge
3d 5m
Merged PRs (30d)
3

Description

When using the cloudformation-cli with the latest setuptools (which needs to be manually installed, see #1067), which currently is `82.0.1`, running any `cfn` command errors with the following error message:
```
/test # cfn generate
Traceback (most recent call last):
File "/usr/local/bin/cfn", line 3, in
from rpdk.core.cli import main
File "/usr/local/lib/python3.13/site-packages/rpdk/core/cli.py", line 12, in
from .build_image import setup_subparser as build_image_setup_subparser
File "/usr/local/lib/python3.13/site-packages/rpdk/core/build_image.py", line 11, in
from .project import Project
File "/usr/local/lib/python3.13/site-packages/rpdk/core/project.py", line 21, in
from rpdk.core.fragment.generator import TemplateFragment
File "/usr/local/lib/python3.13/site-packages/rpdk/core/fragment/generator.py", line 14, in
from rpdk.core.data_loaders import resource_json
File "/usr/local/lib/python3.13/site-packages/rpdk/core/data_loaders.py", line 9, in
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
```

Steps to reproduce:
Running in docker: `docker run -it --rm python:3.13-alpine sh`
- install cfn cli: `pip3 install cloudformation-cli`
- install setuptools: `pip3 install setuptools`
- run `cfn generate`

Expected result:
Some valid cfn error message, such as `Project file /.rpdk-config not found. Have you run 'init' or in a wrong directory?`.

Current result:
```
# cfn generate
Traceback (most recent call last):
File "/usr/local/bin/cfn", line 3, in
from rpdk.core.cli import main
File "/usr/local/lib/python3.13/site-packages/rpdk/core/cli.py", line 12, in
from .build_image import setup_subparser as build_image_setup_subparser
File "/usr/local/lib/python3.13/site-packages/rpdk/core/build_image.py", line 11, in
from .project import Project
File "/usr/local/lib/python3.13/site-packages/rpdk/core/project.py", line 21, in
from rpdk.core.fragment.generator import TemplateFragment
File "/usr/local/lib/python3.13/site-packages/rpdk/core/fragment/generator.py", line 14, in
from rpdk.core.data_loaders import resource_json
File "/usr/local/lib/python3.13/site-packages/rpdk/core/data_loaders.py", line 9, in
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
```

Current workaround:
Install a setuptools version lower or equal than 81.0.0 (`pip3 install setuptools==81.0.0`).

Background:
setuptools starting with 82.0.0 removes the `pkg_resources` package, see:
- https://setuptools.pypa.io/en/latest/history.html#v82-0-0
- https://github.com/pypa/setuptools/pull/5007
- https://stackoverflow.com/questions/7446187/no-module-named-pkg-resources/79888812#79888812

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.