Skip to content

Commit

Permalink
Merge pull request #9169 from pradyunsg/always-reinstall-editables
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg authored Nov 28, 2020
2 parents 8b4652e + 2f90674 commit b6ca743
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
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
ireq.should_reinstall = True
else:
continue
Expand Down

0 comments on commit b6ca743

Please sign in to comment.