Skip to content

Commit

Permalink
Make the WheelCache FormatControl argument optional
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sbidoul committed Apr 5, 2021
1 parent 55742f1 commit 42d3f75
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/pip/_internal/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
7 changes: 6 additions & 1 deletion src/pip/_internal/commands/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 42d3f75

Please sign in to comment.