Skip to content

Commit b2c0487

Browse files
committed
Add comments explaining InstallationError handling
1 parent d45541c commit b2c0487

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ def _prepare(self):
221221
try:
222222
dist = self._prepare_distribution()
223223
except HashError as e:
224+
# Provide HashError the underlying ireq that caused it. This
225+
# provides context for the resulting error message to show the
226+
# offending line to the user.
224227
e.req = self._ireq
225228
raise
226229
self._check_metadata_consistency(dist)

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,12 @@ def _make_candidate_from_link(
137137
# type: (...) -> Optional[Candidate]
138138
# TODO: Check already installed candidate, and use it if the link and
139139
# editable flag match.
140+
140141
if link in self._build_failures:
142+
# We already tried this candidate before, and it does not build.
143+
# Don't bother trying again.
141144
return None
145+
142146
if template.editable:
143147
if link not in self._editable_candidate_cache:
144148
try:
@@ -163,6 +167,7 @@ def _make_candidate_from_link(
163167
self._build_failures[link] = e
164168
return None
165169
base = self._link_candidate_cache[link]
170+
166171
if extras:
167172
return ExtrasCandidate(base, extras)
168173
return base
@@ -296,6 +301,12 @@ def make_requirement_from_install_req(self, ireq, requested_extras):
296301
version=None,
297302
)
298303
if cand is None:
304+
# There's no way we can satisfy a URL requirement if the underlying
305+
# candidate fails to build. An unnamed URL must be user-supplied, so
306+
# we fail eagerly. If the URL is named, an unsatisfiable requirement
307+
# can make the resolver do the right thing, either backtrack (and
308+
# maybe find some other requirement that's buildable) or raise a
309+
# ResolutionImpossible eventually.
299310
if not ireq.name:
300311
raise self._build_failures[ireq.link]
301312
return UnsatisfiableRequirement(canonicalize_name(ireq.name))

0 commit comments

Comments
 (0)