diff --git a/src/pip/_internal/resolution/resolvelib/resolver.py b/src/pip/_internal/resolution/resolvelib/resolver.py index f29b9692bd210c4d80270812827ce21d6eef5c65..2ba1420253628b2d9e84da4474b2580ac02c0fee 100644 --- a/src/pip/_internal/resolution/resolvelib/resolver.py +++ b/src/pip/_internal/resolution/resolvelib/resolver.py @@ -16,6 +16,8 @@ from pip._internal.resolution.resolvelib.reporter import ( PipDebuggingReporter, PipReporter, ) +from pip._internal.utils.deprecation import deprecated +from pip._internal.utils.filetypes import is_archive_file from pip._internal.utils.misc import dist_is_editable from pip._internal.utils.typing import MYPY_CHECK_RUNNING @@ -139,6 +141,7 @@ class Resolver(BaseResolver): # we need to uninstall it to install the new distribution. # * The installed version is different from the pending distribution. # * The candidate is a local wheel. Do nothing. + # * The candidate is a local sdist. Print a deprecation warning. # * The candidate is a local path. Always reinstall. installed_dist = self.factory.get_dist_to_uninstall(candidate) if installed_dist is None: @@ -158,6 +161,19 @@ class Resolver(BaseResolver): ireq.name, ) continue + if is_archive_file(candidate.source_link.file_path): + reason = ( + "Source distribution is being reinstalled despite an " + "installed package having the same name and version as " + "the installed package." + ) + replacement = "use --force-reinstall" + deprecated( + reason=reason, + replacement=replacement, + gone_in="21.1", + issue=8711, + ) ireq.should_reinstall = True else: continue diff --git a/tests/functional/test_new_resolver.py b/tests/functional/test_new_resolver.py index a26786c89aa6ab99ff605d657b9b896bbc945a5d..9a4c98f8a2248600092488e23f06d850eb377484 100644 --- a/tests/functional/test_new_resolver.py +++ b/tests/functional/test_new_resolver.py @@ -1187,8 +1187,10 @@ def test_new_resolver_does_reinstall_local_sdists(script): result = script.pip( "install", "--no-cache-dir", "--no-index", archive_path, + expect_stderr=True, ) assert "Installing collected packages: pkg" in result.stdout, str(result) + assert "DEPRECATION" in result.stderr, str(result) assert_installed(script, pkg="1.0")