From 9c4a88b0a067ccf551279c889c90eec1adfc6144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Wed, 12 Aug 2020 11:07:36 +0200 Subject: [PATCH 1/3] Improve deprecation message for issue 8368 --- src/pip/_internal/commands/install.py | 21 +++------------------ src/pip/_internal/req/req_install.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 77ec210d6af..e41660070a0 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -21,7 +21,6 @@ from pip._internal.operations.check import check_install_conflicts from pip._internal.req import install_given_reqs from pip._internal.req.req_tracker import get_requirement_tracker -from pip._internal.utils.deprecation import deprecated from pip._internal.utils.distutils_args import parse_distutils_args from pip._internal.utils.filesystem import test_writable_dir from pip._internal.utils.misc import ( @@ -371,23 +370,9 @@ def run(self, options, args): # For now, we just warn about failures building legacy # requirements, as we'll fall through to a direct # install for those. - legacy_build_failure_names = [ - r.name # type: ignore - for r in build_failures if not r.use_pep517 - ] # type: List[str] - if legacy_build_failure_names: - deprecated( - reason=( - "Could not build wheels for {} which do not use " - "PEP 517. pip will fall back to legacy 'setup.py " - "install' for these.".format( - ", ".join(legacy_build_failure_names) - ) - ), - replacement="to fix the wheel build issue reported above", - gone_in="21.0", - issue=8368, - ) + for r in build_failures: + if not r.use_pep517: + r.legacy_install_reason = 8368 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 816969f8e62..8f1b661248c 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -121,6 +121,7 @@ def __init__( self.comes_from = comes_from self.constraint = constraint self.editable = editable + self.legacy_install_reason = None # type: Optional[int] # source_dir is the local directory where the linked requirement is # located, or unpacked. In case unpacking is needed, creating and @@ -859,6 +860,18 @@ def install( except Exception: self.install_succeeded = True raise + else: + if 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="21.0", + issue=8368, + ) self.install_succeeded = success From 03d49da397a40d6652493340dde6f6a1661f512b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Thu, 13 Aug 2020 09:31:20 +0200 Subject: [PATCH 2/3] Add news --- news/8752.feature | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 news/8752.feature diff --git a/news/8752.feature b/news/8752.feature new file mode 100644 index 00000000000..d2560da1803 --- /dev/null +++ b/news/8752.feature @@ -0,0 +1,3 @@ +Make the ``setup.py install`` deprecation warning less noisy. We warn only +when ``setup.py install`` succeeded and ``setup.py bdist_wheel`` failed, as +situations where both fails are most probably irrelevant to this deprecation. From 4c348cf3a08f05f498e5a3ad19cc268752de3b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Thu, 13 Aug 2020 09:38:56 +0200 Subject: [PATCH 3/3] Consider success flag instead of absence of exception --- src/pip/_internal/req/req_install.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index 8f1b661248c..4e306be0146 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -860,21 +860,21 @@ def install( except Exception: self.install_succeeded = True raise - else: - if 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="21.0", - issue=8368, - ) 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="21.0", + issue=8368, + ) + def check_invalid_constraint_type(req): # type: (InstallRequirement) -> str