Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace confusing pyproject.toml with backend string in logs #12346

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions docs/html/reference/build-system/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ setup-py
```

<!-- prettier-ignore-start -->
[`pyproject.toml` based](pyproject-toml)
[*Backend API* based](pyproject-toml)
: Standards-backed interface, that has explicit declaration and management of
build dependencies.

Expand All @@ -33,36 +33,50 @@ the build system interfaces that pip may use.

## Determining which build system interface is used

Currently, pip uses the `pyproject.toml` based build system interface, if a
`pyproject.toml` file exists. If not, the legacy build system interface is used.
The intention is to switch to using the `pyproject.toml` build system interface
Currently, pip uses the *backend API* based build system interface, in the
following scenarios:

- if a `pyproject.toml` file exists, or
- if {pypi}`setuptools` or {pypi}`wheel` is not installed.

Otherwise, the legacy build system interface is used.
The intention is to switch to using the *backend API* build system interface
unconditionally and to drop support for the legacy build system interface at
some point in the future.

When performing a build, pip will mention which build system interface it is
using. Typically, this will take the form of a message like:
using. For the *backend API* based build system interface,
typically this will take the form of a message like[^2]:

```none
Building wheel for pip (pyproject.toml)... done
Building wheel for pip (<build backend identification>)... done
```

[^2]: Here `<build backend identification>` is replaced with the actual value for
the given package, e.g. `Building wheel for pip (setuptools.build_meta)... done`

For the `setup.py` based build system interface, typically this will look like
the following:

```none
Building wheel for pip (setup.py)... done
```

The content in the brackets, refers to which build system interface is being
used.

```{versionchanged} 21.3
The output uses "pyproject.toml" instead of "PEP 517" to refer to be
`pyproject.toml` based build system interface.
*backend API* based build system interface.
```

```{versionchanged} 23.X
The output uses the backend specification instead of "pyproject.toml"
to refer to be *backend API* based build system interface.
```

## Controlling which build system interface is used

The [`--use-pep517`](install_--use-pep517) flag (and corresponding environment
variable: `PIP_USE_PEP517`) can be used to force all packages to build using
the `pyproject.toml` based build system interface. There is no way to force
the *backend API* based build system interface. There is no way to force
the use of the legacy build system interface.

(controlling-setup_requires)=
Expand Down
5 changes: 4 additions & 1 deletion docs/html/reference/build-system/pyproject-toml.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `pyproject.toml`
# Backend API

```{versionadded} 10.0

Expand Down Expand Up @@ -168,3 +168,6 @@ changes and improvements in it.
- Prior to pip 18.1, build dependencies using `.pth` files are not properly
supported; as a result namespace packages do not work under Python 3.2 and
earlier.
- Starting from version 23.1, pip uses the fallback behaviour of
`setuptools.build_meta:__legacy__` when `wheel` or `setuptools` are not
installed.
4 changes: 2 additions & 2 deletions docs/html/reference/build-system/setup-py.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# `setup.py` (legacy)

Prior to the introduction of pyproject.toml-based builds (in {pep}`517` and
Prior to the introduction of *backend API* based builds (in {pep}`517` and
{pep}`518`), pip had only supported installing packages using `setup.py` files
that were built using {pypi}`setuptools`.

The interface documented here is retained currently solely for legacy purposes,
until the migration to `pyproject.toml`-based builds can be completed.
until the migration to *backend API* based builds can be completed.

```{caution}
The arguments and syntax of the various invocations of `setup.py` made by
Expand Down
1 change: 1 addition & 0 deletions news/12346.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid referring to "backend API"-based builds as ``pyproject.toml``-based.
1 change: 1 addition & 0 deletions news/12346.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace confusing ``pyproject.toml`` with backend string in logs.
4 changes: 3 additions & 1 deletion src/pip/_internal/operations/build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def generate_metadata(
# Note that BuildBackendHookCaller implements a fallback for
# prepare_metadata_for_build_wheel, so we don't have to
# consider the possibility that this hook doesn't exist.
runner = runner_with_spinner_message("Preparing metadata (pyproject.toml)")
runner = runner_with_spinner_message(
f"Preparing metadata ({backend.build_backend})"
)
with backend.subprocess_runner(runner):
try:
distinfo_dir = backend.prepare_metadata_for_build_wheel(metadata_dir)
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/operations/build/metadata_editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def generate_editable_metadata(
# prepare_metadata_for_build_wheel/editable, so we don't have to
# consider the possibility that this hook doesn't exist.
runner = runner_with_spinner_message(
"Preparing editable metadata (pyproject.toml)"
f"Preparing editable metadata ({backend.build_backend})"
)
with backend.subprocess_runner(runner):
try:
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/operations/build/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def build_wheel_pep517(
logger.debug("Destination directory: %s", tempd)

runner = runner_with_spinner_message(
f"Building wheel for {name} (pyproject.toml)"
f"Building wheel for {name} ({backend.build_backend})"
)
with backend.subprocess_runner(runner):
wheel_name = backend.build_wheel(
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/operations/build/wheel_editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def build_wheel_editable(
logger.debug("Destination directory: %s", tempd)

runner = runner_with_spinner_message(
f"Building editable for {name} (pyproject.toml)"
f"Building editable for {name} ({backend.build_backend})"
)
with backend.subprocess_runner(runner):
try:
Expand Down