Skip to content

Commit 7ce06dd

Browse files
committed
Re-install local candidates unconditionally
Signed-off-by: Pradyun Gedam <[email protected]>
1 parent 1587170 commit 7ce06dd

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,19 @@ def resolve(self, root_reqs, check_supported_wheels):
132132

133133
# Check if there is already an installation under the same name,
134134
# and set a flag for later stages to uninstall it, if needed.
135-
# * There isn't, good -- no uninstalltion needed.
135+
#
136+
# * There is no existing installation. Nothing to uninstall.
137+
# * The candidate is a local path/file. Always reinstall.
136138
# * The --force-reinstall flag is set. Always reinstall.
137139
# * The installation is different in version or editable-ness, so
138140
# we need to uninstall it to install the new distribution.
139141
# * The installed version is the same as the pending distribution.
140-
# Skip this distrubiton altogether to save work.
142+
# Skip this distribution altogether to save work.
141143
installed_dist = self.factory.get_dist_to_uninstall(candidate)
142144
if installed_dist is None:
143145
ireq.should_reinstall = False
146+
elif candidate.source_link.is_file:
147+
ireq.should_reinstall = True
144148
elif self.factory.force_reinstall:
145149
ireq.should_reinstall = True
146150
elif installed_dist.parsed_version != candidate.version:

tests/functional/test_new_resolver.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,3 +1132,43 @@ def test_new_resolver_check_wheel_version_normalized(
11321132
"simple"
11331133
)
11341134
assert_installed(script, simple="0.1.0+local.1")
1135+
1136+
1137+
def test_new_resolver_does_reinstall_local_wheels(script):
1138+
archive_path = create_basic_wheel_for_package(
1139+
script,
1140+
"pkg",
1141+
"1.0",
1142+
)
1143+
script.pip(
1144+
"install", "--no-cache-dir", "--no-index",
1145+
archive_path,
1146+
)
1147+
assert_installed(script, pkg="1.0")
1148+
1149+
result = script.pip(
1150+
"install", "--no-cache-dir", "--no-index",
1151+
archive_path,
1152+
)
1153+
assert "Installing collected packages: pkg" in result.stdout, str(result)
1154+
assert_installed(script, pkg="1.0")
1155+
1156+
1157+
def test_new_resolver_does_reinstall_local_paths(script):
1158+
pkg = create_test_package_with_setup(
1159+
script,
1160+
name="pkg",
1161+
version="1.0"
1162+
)
1163+
script.pip(
1164+
"install", "--no-cache-dir", "--no-index",
1165+
pkg,
1166+
)
1167+
assert_installed(script, pkg="1.0")
1168+
1169+
result = script.pip(
1170+
"install", "--no-cache-dir", "--no-index",
1171+
pkg,
1172+
)
1173+
assert "Installing collected packages: pkg" in result.stdout, str(result)
1174+
assert_installed(script, pkg="1.0")

0 commit comments

Comments
 (0)