diff --git a/src/pip/_internal/cli/cmdoptions.py b/src/pip/_internal/cli/cmdoptions.py index 64bd47d2b68..8839b7a0721 100644 --- a/src/pip/_internal/cli/cmdoptions.py +++ b/src/pip/_internal/cli/cmdoptions.py @@ -969,6 +969,7 @@ def check_list_path_option(options: Values) -> None: "out-of-tree-build", "backtrack-on-build-failures", "html5lib", + "legacy-setup-py-install", ], help=("Enable deprecated functionality, that will be removed in the future."), ) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index db41b9a1b03..8637c6e0c83 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -243,6 +243,9 @@ def run(self, options: Values, args: List[str]) -> int: raise CommandError("Can not combine '--user' and '--target'") cmdoptions.check_install_build_global(options) + should_fallback_to_legacy_install = ( + "legacy-setup-py-install" in options.deprecated_features_enabled + ) upgrade_strategy = "to-satisfy-only" if options.upgrade: upgrade_strategy = options.upgrade_strategy @@ -366,25 +369,25 @@ def run(self, options: Values, args: List[str]) -> int: global_options=[], ) - # If we're using PEP 517, we cannot do a legacy setup.py install - # so we fail here. - pep517_build_failure_names: List[str] = [ - r.name for r in build_failures if r.use_pep517 # type: ignore - ] - if pep517_build_failure_names: - raise InstallationError( - "Could not build wheels for {}, which is required to " - "install pyproject.toml-based projects".format( - ", ".join(pep517_build_failure_names) + if build_failures: + if not should_fallback_to_legacy_install: + raise InstallationError( + "Could not build wheels for {}, which is required to " + "install pyproject.toml-based projects".format( + ", ".join([r.name for r in build_failures]) # type: ignore + ) ) - ) - # For now, we just warn about failures building legacy - # requirements, as we'll fall through to a setup.py install for - # those. - for r in build_failures: - if not r.use_pep517: - r.legacy_install_reason = 8368 + pep517_build_failures = [r for r in build_failures if r.use_pep517] + if pep517_build_failures: + raise InstallationError( + "Could not build wheels for {}, which is required to " + "install pyproject.toml-based projects".format( + ", ".join( + [r.name for r in pep517_build_failures] # type: ignore + ) + ) + ) to_install = resolver.get_installation_order(requirement_set) diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index 637b6ce10af..2910f3ce2fc 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -91,7 +91,6 @@ def __init__( self.constraint = constraint self.editable = editable self.permit_editable_wheels = permit_editable_wheels - self.legacy_install_reason: Optional[int] = None # source_dir is the local directory where the linked requirement is # located, or unpacked. In case unpacking is needed, creating and @@ -788,6 +787,14 @@ def install( global_options = list(global_options) + self.global_options install_options = list(install_options) + self.install_options + deprecated( + reason=( + "Using 'setup.py install' for performing a package installation " + "is deprecated." + ), + replacement="correctly building a wheel for this package", + gone_in="23.0", + ) try: success = install_legacy( install_options=install_options, @@ -814,19 +821,6 @@ def install( self.install_succeeded = success - if success and self.legacy_install_reason == 8368: - deprecated( - reason=( - "{} was installed using the legacy 'setup.py install' " - "method, because a wheel could not be built for it.".format( - self.name - ) - ), - replacement="to fix the wheel build issue reported above", - gone_in=None, - issue=8368, - ) - def check_invalid_constraint_type(req: InstallRequirement) -> str: