diff --git a/news/12256.feature.rst b/news/12256.feature.rst new file mode 100644 index 00000000000..52045cbdce0 --- /dev/null +++ b/news/12256.feature.rst @@ -0,0 +1 @@ +Introduce ``--use-feature=metadata-cache`` to cache metadata lookups in ``~/.cache/pip/link-metadata``. diff --git a/src/pip/_internal/cli/cmdoptions.py b/src/pip/_internal/cli/cmdoptions.py index 02ba6082793..284b87bc507 100644 --- a/src/pip/_internal/cli/cmdoptions.py +++ b/src/pip/_internal/cli/cmdoptions.py @@ -1009,6 +1009,7 @@ def check_list_path_option(options: Values) -> None: choices=[ "fast-deps", "truststore", + "metadata-cache", ] + ALWAYS_ENABLED_FEATURES, help="Enable new functionality, that may be backward incompatible.", diff --git a/src/pip/_internal/cli/req_command.py b/src/pip/_internal/cli/req_command.py index bfc1733960c..93bd7039741 100644 --- a/src/pip/_internal/cli/req_command.py +++ b/src/pip/_internal/cli/req_command.py @@ -308,7 +308,7 @@ def make_requirement_preparer( "fast-deps has no effect when used with the legacy resolver." ) - if options.cache_dir: + if bool(options.cache_dir) and ("metadata-cache" in options.features_enabled): metadata_cache = LinkMetadataCache(options.cache_dir) else: metadata_cache = None