Skip to content

Commit 42d3f75

Browse files
committed
Make the WheelCache FormatControl argument optional
This commit does not change behaviour, but makes the fact that --no-binary does not disable the cache anymore (when always-install-via-wheel is set) more explicit.
1 parent 55742f1 commit 42d3f75

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/pip/_internal/cache.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,10 @@ class WheelCache(Cache):
231231
when a certain link is not found in the simple wheel cache first.
232232
"""
233233

234-
def __init__(self, cache_dir, format_control):
235-
# type: (str, FormatControl) -> None
234+
def __init__(self, cache_dir, format_control=None):
235+
# type: (str, Optional[FormatControl]) -> None
236+
if format_control is None:
237+
format_control = FormatControl()
236238
super().__init__(cache_dir, format_control, {'binary'})
237239
self._wheel_cache = SimpleWheelCache(cache_dir, format_control)
238240
self._ephem_cache = EphemWheelCache(format_control)

src/pip/_internal/commands/install.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,12 @@ def run(self, options, args):
275275
target_python=target_python,
276276
ignore_requires_python=options.ignore_requires_python,
277277
)
278-
wheel_cache = WheelCache(options.cache_dir, options.format_control)
278+
if "always-install-via-wheel" in options.features_enabled:
279+
wheel_cache = WheelCache(options.cache_dir)
280+
else:
281+
# TODO when removing this branch, also remove format control support
282+
# in WheelCache.
283+
wheel_cache = WheelCache(options.cache_dir, options.format_control)
279284

280285
req_tracker = self.enter_context(get_requirement_tracker())
281286

src/pip/_internal/commands/wheel.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,12 @@ def run(self, options, args):
103103
session = self.get_default_session(options)
104104

105105
finder = self._build_package_finder(options, session)
106-
wheel_cache = WheelCache(options.cache_dir, options.format_control)
106+
if "always-install-via-wheel" in options.features_enabled:
107+
wheel_cache = WheelCache(options.cache_dir)
108+
else:
109+
# TODO when removing this branch, also remove format control support
110+
# in WheelCache.
111+
wheel_cache = WheelCache(options.cache_dir, options.format_control)
107112

108113
options.wheel_dir = normalize_path(options.wheel_dir)
109114
ensure_dir(options.wheel_dir)

0 commit comments

Comments
 (0)