Skip to content

Commit 3d279ba

Browse files
authored
Stop bundling setuptools for Python 3.12+ (#301)
For parity with the `ensurepip` and `venv` modules, which no longer install setuptools as of Python 3.12: - python/cpython#95299 - python/cpython@ece20db Fixes #300.
1 parent 523c1ed commit 3d279ba

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

cpython-unix/build-cpython.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,12 @@ fi
575575
# simply use our pip to install self. Kinda crazy, but it works!
576576

577577
${BUILD_PYTHON} "${PIP_WHEEL}/pip" install --prefix="${ROOT}/out/python/install" --no-cache-dir --no-index "${PIP_WHEEL}"
578-
${BUILD_PYTHON} "${PIP_WHEEL}/pip" install --prefix="${ROOT}/out/python/install" --no-cache-dir --no-index "${SETUPTOOLS_WHEEL}"
578+
579+
# Setuptools is only installed for Python 3.11 and older, for parity with
580+
# `ensurepip` and `venv`: https://github.com/python/cpython/pull/101039
581+
if [ -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_11}" ]; then
582+
${BUILD_PYTHON} "${PIP_WHEEL}/pip" install --prefix="${ROOT}/out/python/install" --no-cache-dir --no-index "${SETUPTOOLS_WHEEL}"
583+
fi
579584

580585
# Hack up the system configuration settings to aid portability.
581586
#

cpython-windows/build.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from pythonbuild.cpython import (
2121
STDLIB_TEST_PACKAGES,
22+
meets_python_maximum_version,
2223
meets_python_minimum_version,
2324
parse_config_c,
2425
)
@@ -1653,19 +1654,22 @@ def build_cpython(
16531654
pip_env,
16541655
)
16551656

1656-
exec_and_log(
1657-
[
1658-
str(install_dir / "python.exe"),
1659-
"-m",
1660-
"pip",
1661-
"install",
1662-
"--no-cache-dir",
1663-
"--no-index",
1664-
str(setuptools_wheel),
1665-
],
1666-
td,
1667-
pip_env,
1668-
)
1657+
# Setuptools is only installed for Python 3.11 and older, for parity with
1658+
# `ensurepip` and `venv`: https://github.com/python/cpython/pull/101039
1659+
if meets_python_maximum_version(python_version, "3.11"):
1660+
exec_and_log(
1661+
[
1662+
str(install_dir / "python.exe"),
1663+
"-m",
1664+
"pip",
1665+
"install",
1666+
"--no-cache-dir",
1667+
"--no-index",
1668+
str(setuptools_wheel),
1669+
],
1670+
td,
1671+
pip_env,
1672+
)
16691673

16701674
# The executables in the Scripts/ directory don't work because they reference
16711675
# python.dll in the wrong path. You can run these via e.g. `python.exe -m pip`.

docs/running.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ Extra Python Software
259259
Python installations have some additional software pre-installed:
260260

261261
* `pip <https://pypi.org/project/pip/>`_
262-
* `setuptools <https://pypi.org/project/setuptools/>`_
262+
* `setuptools <https://pypi.org/project/setuptools/>`_ (for Python 3.11 and older)
263263

264264
The intent of the pre-installed software is to facilitate end-user
265265
package installation without having to first bootstrap a packaging

0 commit comments

Comments
 (0)