From c12139de9b51da9947d3b36b4f0e2e0c8f467663 Mon Sep 17 00:00:00 2001 From: Paul Moore Date: Tue, 18 Jul 2023 20:50:10 +0100 Subject: [PATCH 1/2] Disable PEP 658 for the legacy resolver --- news/12156.bugfix.rst | 1 + src/pip/_internal/cli/req_command.py | 3 +++ src/pip/_internal/operations/prepare.py | 9 +++++++++ 3 files changed, 13 insertions(+) create mode 100644 news/12156.bugfix.rst diff --git a/news/12156.bugfix.rst b/news/12156.bugfix.rst new file mode 100644 index 00000000000..da0be566d91 --- /dev/null +++ b/news/12156.bugfix.rst @@ -0,0 +1 @@ +Disable PEP 658 metadata fetching with the legacy resolver. diff --git a/src/pip/_internal/cli/req_command.py b/src/pip/_internal/cli/req_command.py index c2f4e38bed8..86070f10c14 100644 --- a/src/pip/_internal/cli/req_command.py +++ b/src/pip/_internal/cli/req_command.py @@ -287,6 +287,7 @@ def make_requirement_preparer( """ temp_build_dir_path = temp_build_dir.path assert temp_build_dir_path is not None + legacy_resolver = False resolver_variant = cls.determine_resolver_variant(options) if resolver_variant == "2020-resolver": @@ -300,6 +301,7 @@ def make_requirement_preparer( "production." ) else: + legacy_resolver = True lazy_wheel = False if "fast-deps" in options.features_enabled: logger.warning( @@ -320,6 +322,7 @@ def make_requirement_preparer( use_user_site=use_user_site, lazy_wheel=lazy_wheel, verbosity=verbosity, + legacy_resolver=legacy_resolver, ) @classmethod diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index 49d86268a3b..cb121bcb252 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -226,6 +226,7 @@ def __init__( use_user_site: bool, lazy_wheel: bool, verbosity: int, + legacy_resolver: bool, ) -> None: super().__init__() @@ -259,6 +260,9 @@ def __init__( # How verbose should underlying tooling be? self.verbosity = verbosity + # Are we using the legacy resolver? + self.legacy_resolver = legacy_resolver + # Memoized downloaded files, as mapping of url: path. self._downloaded: Dict[str, str] = {} @@ -365,6 +369,11 @@ def _fetch_metadata_only( self, req: InstallRequirement, ) -> Optional[BaseDistribution]: + if self.legacy_resolver: + logger.debug( + "Metadata-only fetching is not used in the legacy resolver", + ) + return None if self.require_hashes: logger.debug( "Metadata-only fetching is not used as hash checking is required", From 39aa7ed50e26d77a4a277fa525add44b6f7b3bcd Mon Sep 17 00:00:00 2001 From: Paul Moore Date: Tue, 18 Jul 2023 21:00:11 +0100 Subject: [PATCH 2/2] Fix a direct creation of RequirementPreparer in the tests --- tests/unit/test_req.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/test_req.py b/tests/unit/test_req.py index 74b9712dc03..545828f8eea 100644 --- a/tests/unit/test_req.py +++ b/tests/unit/test_req.py @@ -105,6 +105,7 @@ def _basic_resolver( use_user_site=False, lazy_wheel=False, verbosity=0, + legacy_resolver=True, ) yield Resolver( preparer=preparer,