Skip to content

Commit

Permalink
WheelCache optional FormatControl
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Jan 9, 2021
1 parent 7542e74 commit 164e3ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/pip/_internal/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pip._vendor.packaging.utils import canonicalize_name

from pip._internal.exceptions import InvalidWheelFilename
from pip._internal.models.format_control import FormatControl
from pip._internal.models.link import Link
from pip._internal.models.wheel import Wheel
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
Expand All @@ -21,8 +22,6 @@

from pip._vendor.packaging.tags import Tag

from pip._internal.models.format_control import FormatControl

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -280,8 +279,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
5 changes: 4 additions & 1 deletion src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ 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:
wheel_cache = WheelCache(options.cache_dir, options.format_control)

req_tracker = self.enter_context(get_requirement_tracker())

Expand Down
5 changes: 4 additions & 1 deletion src/pip/_internal/commands/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ 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:
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 164e3ea

Please sign in to comment.