Skip to content
2 changes: 2 additions & 0 deletions news/14238.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``inprocess-build-deps`` reports started/finished status when printing to a
non-interactive terminal properly.
6 changes: 3 additions & 3 deletions src/pip/_internal/build_env/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from typing import TYPE_CHECKING

from pip._internal.build_env.base import Prefix
from pip._internal.cli.spinners import open_rich_spinner, open_spinner
from pip._internal.cli.spinners import open_spinner
from pip._internal.exceptions import (
BuildDependencyInstallError,
DiagnosticPipError,
Expand Down Expand Up @@ -143,7 +143,7 @@ def install(
identify_requirement = (
f" for {for_req.name}" if for_req and for_req.name else ""
)
with open_spinner(f"Installing {kind}") as spinner:
with open_spinner(f"Installing {kind}", autostart=False) as spinner:
call_subprocess(
args,
command_desc=f"installing {kind}{identify_requirement}",
Expand Down Expand Up @@ -225,7 +225,7 @@ def install(
# Hide the logs from the installation of build dependencies.
# They will be shown only if an error occurs.
capture_ctx: ContextManager[StringIO] = capture_logging()
spinner: ContextManager[None] = open_rich_spinner(f"Installing {kind}")
spinner: ContextManager[object] = open_spinner(f"Installing {kind}")
else:
# Otherwise, pass-through all logs (with a header).
capture_ctx, spinner = nullcontext(StringIO()), nullcontext()
Expand Down
16 changes: 15 additions & 1 deletion src/pip/_internal/cli/progress_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import functools
import sys
import time
from collections.abc import Callable, Generator, Iterable, Iterator
from typing import TYPE_CHECKING, Literal, TypeVar

Expand All @@ -19,7 +20,6 @@
TransferSpeedColumn,
)

from pip._internal.cli.spinners import RateLimiter
from pip._internal.utils.logging import get_console, get_indentation

if TYPE_CHECKING:
Expand All @@ -30,6 +30,20 @@
BarType = Literal["on", "off", "raw"]


class RateLimiter:
def __init__(self, min_update_interval_seconds: float) -> None:
self._min_update_interval_seconds = min_update_interval_seconds
self._last_update: float = 0

def ready(self) -> bool:
now = time.time()
delta = now - self._last_update
return delta >= self._min_update_interval_seconds

def reset(self) -> None:
self._last_update = time.time()


def _rich_download_progress_bar(
iterable: Iterable[bytes],
*,
Expand Down
Loading