Skip to content

Commit 8978322

Browse files
committed
WheelCache optional FormatControl
1 parent a093e6d commit 8978322

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/pip/_internal/cache.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pip._vendor.packaging.utils import canonicalize_name
1111

1212
from pip._internal.exceptions import InvalidWheelFilename
13+
from pip._internal.models.format_control import FormatControl
1314
from pip._internal.models.link import Link
1415
from pip._internal.models.wheel import Wheel
1516
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
@@ -21,8 +22,6 @@
2122

2223
from pip._vendor.packaging.tags import Tag
2324

24-
from pip._internal.models.format_control import FormatControl
25-
2625
logger = logging.getLogger(__name__)
2726

2827

@@ -280,8 +279,10 @@ class WheelCache(Cache):
280279
when a certain link is not found in the simple wheel cache first.
281280
"""
282281

283-
def __init__(self, cache_dir, format_control):
284-
# type: (str, FormatControl) -> None
282+
def __init__(self, cache_dir, format_control=None):
283+
# type: (str, Optional[FormatControl]) -> None
284+
if format_control is None:
285+
format_control = FormatControl()
285286
super().__init__(cache_dir, format_control, {'binary'})
286287
self._wheel_cache = SimpleWheelCache(cache_dir, format_control)
287288
self._ephem_cache = EphemWheelCache(format_control)

src/pip/_internal/commands/install.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ def run(self, options, args):
276276
target_python=target_python,
277277
ignore_requires_python=options.ignore_requires_python,
278278
)
279-
wheel_cache = WheelCache(options.cache_dir, options.format_control)
279+
if "always-install-via-wheel" in options.features_enabled:
280+
wheel_cache = WheelCache(options.cache_dir)
281+
else:
282+
wheel_cache = WheelCache(options.cache_dir, options.format_control)
280283

281284
req_tracker = self.enter_context(get_requirement_tracker())
282285

src/pip/_internal/commands/wheel.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ def run(self, options, args):
105105
session = self.get_default_session(options)
106106

107107
finder = self._build_package_finder(options, session)
108-
wheel_cache = WheelCache(options.cache_dir, options.format_control)
108+
if "always-install-via-wheel" in options.features_enabled:
109+
wheel_cache = WheelCache(options.cache_dir)
110+
else:
111+
wheel_cache = WheelCache(options.cache_dir, options.format_control)
109112

110113
options.wheel_dir = normalize_path(options.wheel_dir)
111114
ensure_dir(options.wheel_dir)

0 commit comments

Comments
 (0)