From 0cabefbce800b6bde91f869e83dc48bd0ea4aa64 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Wed, 12 Jul 2023 02:54:10 +0800 Subject: [PATCH] Ensure requirements are prepared before get_dist() 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. --- src/pip/_internal/commands/download.py | 5 ++++- src/pip/_internal/commands/wheel.py | 4 +++- src/pip/_internal/resolution/resolvelib/resolver.py | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pip/_internal/commands/download.py b/src/pip/_internal/commands/download.py index 63bd53a50c8..54247a78a65 100644 --- a/src/pip/_internal/commands/download.py +++ b/src/pip/_internal/commands/download.py @@ -130,7 +130,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() downloaded: List[str] = [] for req in requirement_set.requirements.values(): @@ -138,6 +137,10 @@ def run(self, options: Values, args: List[str]) -> int: 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)) diff --git a/src/pip/_internal/commands/wheel.py b/src/pip/_internal/commands/wheel.py index e6735bd8da7..ed578aa2500 100644 --- a/src/pip/_internal/commands/wheel.py +++ b/src/pip/_internal/commands/wheel.py @@ -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(): @@ -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, diff --git a/src/pip/_internal/resolution/resolvelib/resolver.py b/src/pip/_internal/resolution/resolvelib/resolver.py index 47bbfecce36..d5b238608b2 100644 --- a/src/pip/_internal/resolution/resolvelib/resolver.py +++ b/src/pip/_internal/resolution/resolvelib/resolver.py @@ -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(