Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always reinstall editables #9169

Merged
merged 3 commits into from
Nov 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/9169.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
New Resolver: editable installations are done, regardless of whether
the already-installed distribution is editable.
20 changes: 11 additions & 9 deletions src/pip/_internal/resolution/resolvelib/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,24 @@ 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:
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://
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 "
Expand All @@ -166,6 +165,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 "
Expand All @@ -178,6 +178,8 @@ def resolve(self, root_reqs, check_supported_wheels):
gone_in="21.1",
issue=8711,
)

# is a local sdist or path -- reinstall
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case did cover the editable reinstall from local directory. This PR alsos covers editable reinstall of VCS urls 👍

ireq.should_reinstall = True
else:
continue
Expand Down