From 2617ccd8a3a46fb38bd9794d81cc8b9b6fd07602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Wed, 29 Mar 2023 08:40:02 +0200 Subject: [PATCH] Centralize warning about always enabled features --- src/pip/_internal/cli/base_command.py | 9 +++++++++ src/pip/_internal/cli/cmdoptions.py | 9 +++++++-- src/pip/_internal/commands/install.py | 3 --- src/pip/_internal/commands/wheel.py | 3 --- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/pip/_internal/cli/base_command.py b/src/pip/_internal/cli/base_command.py index 5bd7e67e6..637fba18c 100644 --- a/src/pip/_internal/cli/base_command.py +++ b/src/pip/_internal/cli/base_command.py @@ -122,6 +122,15 @@ class Command(CommandContextMixIn): user_log_file=options.log, ) + always_enabled_features = set(options.features_enabled) & set( + cmdoptions.ALWAYS_ENABLED_FEATURES + ) + if always_enabled_features: + logger.warning( + "The following features are always enabled: %s. ", + ", ".join(sorted(always_enabled_features)), + ) + # TODO: Try to get these passing down from the command? # without resorting to os.environ to hold these. # This also affects isolated builds and it should. diff --git a/src/pip/_internal/cli/cmdoptions.py b/src/pip/_internal/cli/cmdoptions.py index 34b5144b0..7f72332db 100644 --- a/src/pip/_internal/cli/cmdoptions.py +++ b/src/pip/_internal/cli/cmdoptions.py @@ -994,6 +994,11 @@ no_python_version_warning: Callable[..., Option] = partial( ) +# Features that are now always on. A warning is printed if they are used. +ALWAYS_ENABLED_FEATURES = [ + "no-binary-enable-wheel-cache", # always on since 23.1 +] + use_new_feature: Callable[..., Option] = partial( Option, "--use-feature", @@ -1004,8 +1009,8 @@ use_new_feature: Callable[..., Option] = partial( choices=[ "fast-deps", "truststore", - "no-binary-enable-wheel-cache", # now always on - ], + ] + + ALWAYS_ENABLED_FEATURES, help="Enable new functionality, that may be backward incompatible.", ) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 7bc17be5a..e9fc7ee3a 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -343,9 +343,6 @@ class InstallCommand(RequirementCommand): reqs = self.get_requirements(args, options, finder, session) check_legacy_setup_py_options(options, reqs) - if "no-binary-enable-wheel-cache" in options.features_enabled: - logger.warning("no-binary-enable-wheel-cache is now active by default.") - wheel_cache = WheelCache(options.cache_dir) # Only when installing is it permitted to use PEP 660. diff --git a/src/pip/_internal/commands/wheel.py b/src/pip/_internal/commands/wheel.py index d1e619c63..c6a588ff0 100644 --- a/src/pip/_internal/commands/wheel.py +++ b/src/pip/_internal/commands/wheel.py @@ -120,9 +120,6 @@ class WheelCommand(RequirementCommand): reqs = self.get_requirements(args, options, finder, session) check_legacy_setup_py_options(options, reqs) - if "no-binary-enable-wheel-cache" in options.features_enabled: - logger.warning("no-binary-enable-wheel-cache is now active by default.") - wheel_cache = WheelCache(options.cache_dir) preparer = self.make_requirement_preparer(