diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 302bc63f67d..056eb8866a0 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -27,7 +27,11 @@ with_cleanup, ) from pip._internal.cli.status_codes import ERROR, SUCCESS -from pip._internal.exceptions import CommandError, InstallationError +from pip._internal.exceptions import ( + CommandError, + InstallationError, + InstallWheelBuildError, +) from pip._internal.locations import get_scheme from pip._internal.metadata import get_environment from pip._internal.models.installation_report import InstallationReport @@ -434,12 +438,7 @@ def run(self, options: Values, args: list[str]) -> int: ) if build_failures: - raise InstallationError( - "Failed to build installable wheels for some " - "pyproject.toml based projects ({})".format( - ", ".join(r.name for r in build_failures) # type: ignore - ) - ) + raise InstallWheelBuildError(build_failures) to_install = resolver.get_installation_order(requirement_set) diff --git a/src/pip/_internal/exceptions.py b/src/pip/_internal/exceptions.py index 0661897e944..98f95494c62 100644 --- a/src/pip/_internal/exceptions.py +++ b/src/pip/_internal/exceptions.py @@ -865,3 +865,17 @@ def __init__(self) -> None: ), link="https://pip.pypa.io/en/stable/topics/dependency-resolution/#handling-resolution-too-deep-errors", ) + + +class InstallWheelBuildError(DiagnosticPipError): + reference = "failed-wheel-build-for-install" + + def __init__(self, failed: list[InstallRequirement]) -> None: + super().__init__( + message=( + "Failed to build installable wheels for some " + "pyproject.toml based projects" + ), + context=", ".join(r.name for r in failed), # type: ignore + hint_stmt=None, + )