Skip to content

Commit

Permalink
Stop bundling setuptools for Python 3.12+
Browse files Browse the repository at this point in the history
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 indygreg#300.
  • Loading branch information
edmorley committed Sep 7, 2024
1 parent 483e6a4 commit def7bc2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
7 changes: 6 additions & 1 deletion cpython-unix/build-cpython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,12 @@ fi
# simply use our pip to install self. Kinda crazy, but it works!

${BUILD_PYTHON} "${PIP_WHEEL}/pip" install --prefix="${ROOT}/out/python/install" --no-cache-dir --no-index "${PIP_WHEEL}"
${BUILD_PYTHON} "${PIP_WHEEL}/pip" install --prefix="${ROOT}/out/python/install" --no-cache-dir --no-index "${SETUPTOOLS_WHEEL}"

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

# Hack up the system configuration settings to aid portability.
#
Expand Down
30 changes: 17 additions & 13 deletions cpython-windows/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from pythonbuild.cpython import (
STDLIB_TEST_PACKAGES,
meets_python_maximum_version,
meets_python_minimum_version,
parse_config_c,
)
Expand Down Expand Up @@ -1653,19 +1654,22 @@ def build_cpython(
pip_env,
)

exec_and_log(
[
str(install_dir / "python.exe"),
"-m",
"pip",
"install",
"--no-cache-dir",
"--no-index",
str(setuptools_wheel),
],
td,
pip_env,
)
# Setuptools is only installed for Python 3.11 and older, for parity with
# `ensurepip` and `venv`: https://github.com/python/cpython/pull/101039
if meets_python_maximum_version(python_version, "3.11"):
exec_and_log(
[
str(install_dir / "python.exe"),
"-m",
"pip",
"install",
"--no-cache-dir",
"--no-index",
str(setuptools_wheel),
],
td,
pip_env,
)

# The executables in the Scripts/ directory don't work because they reference
# python.dll in the wrong path. You can run these via e.g. `python.exe -m pip`.
Expand Down
2 changes: 1 addition & 1 deletion docs/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Extra Python Software
Python installations have some additional software pre-installed:

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

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

0 comments on commit def7bc2

Please sign in to comment.