From 9f4c5409d08c66e846819049c950fdf3d9804ccb Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Sat, 28 Nov 2020 13:54:39 +0000 Subject: [PATCH 1/3] :art: Breakup and move comment Signed-off-by: Pradyun Gedam --- .../_internal/resolution/resolvelib/resolver.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pip/_internal/resolution/resolvelib/resolver.py b/src/pip/_internal/resolution/resolvelib/resolver.py index 9053c871d8e..6b752bd654c 100644 --- a/src/pip/_internal/resolution/resolvelib/resolver.py +++ b/src/pip/_internal/resolution/resolvelib/resolver.py @@ -134,25 +134,23 @@ def resolve(self, root_reqs, check_supported_wheels): # Check if there is already an installation under the same name, # and set a flag for later stages to uninstall it, if needed. - # - # * There is no existing installation. Nothing to uninstall. - # * The --force-reinstall flag is set. Always reinstall. - # * The installation is different in version or editable-ness, so - # we need to uninstall it to install the new 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: + # There is no existing installation -- nothing to uninstall. ireq.should_reinstall = False elif self.factory.force_reinstall: + # The --force-reinstall flag is set -- reinstall. ireq.should_reinstall = True elif installed_dist.parsed_version != candidate.version: + # The installation is different in version -- reinstall. ireq.should_reinstall = True elif dist_is_editable(installed_dist) != candidate.is_editable: + # The installation is different in editable-ness -- reinstall. ireq.should_reinstall = True elif candidate.source_link.is_file: + # The incoming distribution is under file:// if candidate.source_link.is_wheel: + # is a local wheel -- do nothing. logger.info( "%s is already installed with the same version as the " "provided wheel. Use --force-reinstall to force an " @@ -166,6 +164,7 @@ def resolve(self, root_reqs, check_supported_wheels): and candidate.source_link.ext != ".zip" ) if looks_like_sdist: + # is a local sdist -- show a deprecation warning! reason = ( "Source distribution is being reinstalled despite an " "installed package having the same name and version as " @@ -178,6 +177,8 @@ def resolve(self, root_reqs, check_supported_wheels): gone_in="21.1", issue=8711, ) + + # is a local sdist or path -- reinstall ireq.should_reinstall = True else: continue From 1133342f300f5dcc3ac404560e1577a16545f9e5 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Sat, 28 Nov 2020 13:56:40 +0000 Subject: [PATCH 2/3] Always reinstall editables Signed-off-by: Pradyun Gedam --- src/pip/_internal/resolution/resolvelib/resolver.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pip/_internal/resolution/resolvelib/resolver.py b/src/pip/_internal/resolution/resolvelib/resolver.py index 6b752bd654c..30b860f6c48 100644 --- a/src/pip/_internal/resolution/resolvelib/resolver.py +++ b/src/pip/_internal/resolution/resolvelib/resolver.py @@ -144,8 +144,9 @@ def resolve(self, root_reqs, check_supported_wheels): elif installed_dist.parsed_version != candidate.version: # The installation is different in version -- reinstall. ireq.should_reinstall = True - elif dist_is_editable(installed_dist) != candidate.is_editable: - # The installation is different in editable-ness -- reinstall. + elif candidate.is_editable or dist_is_editable(installed_dist): + # The incoming distribution is editable, or different in + # editable-ness to installation -- reinstall. ireq.should_reinstall = True elif candidate.source_link.is_file: # The incoming distribution is under file:// From 2f9067408eec1f47abf146f12715602644dd1bae Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Sat, 28 Nov 2020 14:01:32 +0000 Subject: [PATCH 3/3] :newspaper: Signed-off-by: Pradyun Gedam --- news/9169.bugfix.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 news/9169.bugfix.rst diff --git a/news/9169.bugfix.rst b/news/9169.bugfix.rst new file mode 100644 index 00000000000..299ec273366 --- /dev/null +++ b/news/9169.bugfix.rst @@ -0,0 +1,2 @@ +New Resolver: editable installations are done, regardless of whether +the already-installed distribution is editable.