diff --git a/src/pip/_internal/cache.py b/src/pip/_internal/cache.py index 7ef51b92e1d..6503d416ab2 100644 --- a/src/pip/_internal/cache.py +++ b/src/pip/_internal/cache.py @@ -231,8 +231,10 @@ class WheelCache(Cache): when a certain link is not found in the simple wheel cache first. """ - def __init__(self, cache_dir, format_control): - # type: (str, FormatControl) -> None + def __init__(self, cache_dir, format_control=None): + # type: (str, Optional[FormatControl]) -> None + if format_control is None: + format_control = FormatControl() super().__init__(cache_dir, format_control, {'binary'}) self._wheel_cache = SimpleWheelCache(cache_dir, format_control) self._ephem_cache = EphemWheelCache(format_control) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 20d0d86d948..20592251edf 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -275,7 +275,12 @@ def run(self, options, args): target_python=target_python, ignore_requires_python=options.ignore_requires_python, ) - wheel_cache = WheelCache(options.cache_dir, options.format_control) + if "always-install-via-wheel" in options.features_enabled: + wheel_cache = WheelCache(options.cache_dir) + else: + # TODO when removing this branch, also remove format control support + # in WheelCache. + wheel_cache = WheelCache(options.cache_dir, options.format_control) req_tracker = self.enter_context(get_requirement_tracker()) diff --git a/src/pip/_internal/commands/wheel.py b/src/pip/_internal/commands/wheel.py index ff47dbac51c..2c9abb10ca3 100644 --- a/src/pip/_internal/commands/wheel.py +++ b/src/pip/_internal/commands/wheel.py @@ -103,7 +103,12 @@ def run(self, options, args): session = self.get_default_session(options) finder = self._build_package_finder(options, session) - wheel_cache = WheelCache(options.cache_dir, options.format_control) + if "always-install-via-wheel" in options.features_enabled: + wheel_cache = WheelCache(options.cache_dir) + else: + # TODO when removing this branch, also remove format control support + # in WheelCache. + wheel_cache = WheelCache(options.cache_dir, options.format_control) options.wheel_dir = normalize_path(options.wheel_dir) ensure_dir(options.wheel_dir)