Skip to content

Commit b6ca743

Browse files
authored
Merge pull request #9169 from pradyunsg/always-reinstall-editables
2 parents 8b4652e + 2f90674 commit b6ca743

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

news/9169.bugfix.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
New Resolver: editable installations are done, regardless of whether
2+
the already-installed distribution is editable.

src/pip/_internal/resolution/resolvelib/resolver.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,24 @@ def resolve(self, root_reqs, check_supported_wheels):
134134

135135
# Check if there is already an installation under the same name,
136136
# and set a flag for later stages to uninstall it, if needed.
137-
#
138-
# * There is no existing installation. Nothing to uninstall.
139-
# * The --force-reinstall flag is set. Always reinstall.
140-
# * The installation is different in version or editable-ness, so
141-
# we need to uninstall it to install the new distribution.
142-
# * The candidate is a local wheel. Do nothing.
143-
# * The candidate is a local sdist. Print a deprecation warning.
144-
# * The candidate is a local path. Always reinstall.
145137
installed_dist = self.factory.get_dist_to_uninstall(candidate)
146138
if installed_dist is None:
139+
# There is no existing installation -- nothing to uninstall.
147140
ireq.should_reinstall = False
148141
elif self.factory.force_reinstall:
142+
# The --force-reinstall flag is set -- reinstall.
149143
ireq.should_reinstall = True
150144
elif installed_dist.parsed_version != candidate.version:
145+
# The installation is different in version -- reinstall.
151146
ireq.should_reinstall = True
152-
elif dist_is_editable(installed_dist) != candidate.is_editable:
147+
elif candidate.is_editable or dist_is_editable(installed_dist):
148+
# The incoming distribution is editable, or different in
149+
# editable-ness to installation -- reinstall.
153150
ireq.should_reinstall = True
154151
elif candidate.source_link.is_file:
152+
# The incoming distribution is under file://
155153
if candidate.source_link.is_wheel:
154+
# is a local wheel -- do nothing.
156155
logger.info(
157156
"%s is already installed with the same version as the "
158157
"provided wheel. Use --force-reinstall to force an "
@@ -166,6 +165,7 @@ def resolve(self, root_reqs, check_supported_wheels):
166165
and candidate.source_link.ext != ".zip"
167166
)
168167
if looks_like_sdist:
168+
# is a local sdist -- show a deprecation warning!
169169
reason = (
170170
"Source distribution is being reinstalled despite an "
171171
"installed package having the same name and version as "
@@ -178,6 +178,8 @@ def resolve(self, root_reqs, check_supported_wheels):
178178
gone_in="21.1",
179179
issue=8711,
180180
)
181+
182+
# is a local sdist or path -- reinstall
181183
ireq.should_reinstall = True
182184
else:
183185
continue

0 commit comments

Comments
 (0)