Skip to content

Stop bundling setuptools for Python 3.12+ #300

@edmorley

Description

@edmorley

In Python 3.12, the stdlib's ensurepip and venv modules were updated to no longer install setuptools alongside pip. This was viable since as of pip v22.1, for pre-PEP-517/518 packages pip will now default to the isolated build environment mode (along with a fallback legacy setuptools build backend, with setuptools and wheel automatically installed), if the setuptools package isn't installed globally.

As such, when using the default Python configure options (which include --with-ensurepip, which causes ensurepip to run during the build), the resultant Python build only includes pip and not setuptools for Python 3.12+.

For example, this then means the Python distribution used by the official GitHub Actions setup-python action (which don't override the upstream CPython configure defaults) automatically only ships setuptools for Python 3.11 and older:

# Python 3.11
$ curl -sSfL https://github.com/actions/python-versions/releases/download/3.11.9-9947079978/python-3.11.9-linux-24.04-arm64.tar.gz | tar -zt | grep -E 'site-packages/[^/]+/$'
./lib/python3.11/site-packages/pip-24.0.dist-info/
./lib/python3.11/site-packages/_distutils_hack/
./lib/python3.11/site-packages/pkg_resources/
./lib/python3.11/site-packages/pip/
./lib/python3.11/site-packages/setuptools/
./lib/python3.11/site-packages/setuptools-65.5.0.dist-info/
# Python 3.12
$ curl -sSfL https://github.com/actions/python-versions/releases/download/3.12.5-10375840348/python-3.12.5-linux-24.04-arm64.tar.gz | tar -zt | grep -E 'site-packages/[^/]+/$'
./lib/python3.12/site-packages/pip-24.2.dist-info/
./lib/python3.12/site-packages/pip/

However, the builds performed by this project configure Python using --without-ensurepip, and then manually install pip and setuptools afterwards:
https://github.com/indygreg/python-build-standalone/blob/90d40b46d929eabafee1e3320ab54d32efdf258e/cpython-unix/build-cpython.sh#L546-L547

This means that when Python 3.12 builds were added in 2a5f3a9 they didn't automatically pick up this upstream CPython change.

For parity with upstream Python's behaviour, the builds here should stop explicitly installing setuptools for Python 3.12+.

See also:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions