Skip to content

Commit

Permalink
Ensure requirements are prepared before get_dist()
Browse files Browse the repository at this point in the history
The legacy resolver seems to prepare requirements differently that can
leave them half-done in certain code paths. I'm not quite sure how it's
doing things, but at least we can do this to make sure they do things
right.
  • Loading branch information
uranusjr committed Jul 11, 2023
1 parent ea727e4 commit 0cabefb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/pip/_internal/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,17 @@ def run(self, options: Values, args: List[str]) -> int:
self.trace_basic_info(finder)

requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
requirement_set.warn_legacy_versions_and_specifiers()

downloaded: List[str] = []
for req in requirement_set.requirements.values():
if req.satisfied_by is None:
assert req.name is not None
preparer.save_linked_requirement(req)
downloaded.append(req.name)

preparer.prepare_linked_requirements_more(requirement_set.requirements.values())
requirement_set.warn_legacy_versions_and_specifiers()

if downloaded:
write_output("Successfully downloaded %s", " ".join(downloaded))

Expand Down
4 changes: 3 additions & 1 deletion src/pip/_internal/commands/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def run(self, options: Values, args: List[str]) -> int:
self.trace_basic_info(finder)

requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
requirement_set.warn_legacy_versions_and_specifiers()

reqs_to_build: List[InstallRequirement] = []
for req in requirement_set.requirements.values():
Expand All @@ -154,6 +153,9 @@ def run(self, options: Values, args: List[str]) -> int:
elif should_build_for_wheel_command(req):
reqs_to_build.append(req)

preparer.prepare_linked_requirements_more(requirement_set.requirements.values())
requirement_set.warn_legacy_versions_and_specifiers()

# build wheels
build_successes, build_failures = build(
reqs_to_build,
Expand Down
3 changes: 3 additions & 0 deletions src/pip/_internal/resolution/resolvelib/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ def resolve(

reqs = req_set.all_requirements
self.factory.preparer.prepare_linked_requirements_more(reqs)
for req in reqs:
req.prepared = True
req.needs_more_preparation = False
return req_set

def get_installation_order(
Expand Down

0 comments on commit 0cabefb

Please sign in to comment.