Skip to content

Commit 7b9db94

Browse files
committed
Deprecate --no-binary disabling the wheel cache
1 parent bad03ef commit 7b9db94

File tree

4 files changed

+54
-5
lines changed

4 files changed

+54
-5
lines changed

src/pip/_internal/cache.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,11 @@ class WheelCache(Cache):
221221
when a certain link is not found in the simple wheel cache first.
222222
"""
223223

224-
def __init__(self, cache_dir: str, format_control: FormatControl) -> None:
224+
def __init__(
225+
self, cache_dir: str, format_control: Optional[FormatControl] = None
226+
) -> None:
227+
if format_control is None:
228+
format_control = FormatControl()
225229
super().__init__(cache_dir, format_control, {"binary"})
226230
self._wheel_cache = SimpleWheelCache(cache_dir, format_control)
227231
self._ephem_cache = EphemWheelCache(format_control)

src/pip/_internal/cli/cmdoptions.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,12 @@ def check_list_path_option(options: Values) -> None:
10071007
metavar="feature",
10081008
action="append",
10091009
default=[],
1010-
choices=["2020-resolver", "fast-deps", "truststore"],
1010+
choices=[
1011+
"2020-resolver",
1012+
"fast-deps",
1013+
"truststore",
1014+
"no-binary-enable-wheel-cache",
1015+
],
10111016
help="Enable new functionality, that may be backward incompatible.",
10121017
)
10131018

src/pip/_internal/commands/install.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
from pip._internal.req import install_given_reqs
3030
from pip._internal.req.req_install import InstallRequirement
3131
from pip._internal.utils.compat import WINDOWS
32-
from pip._internal.utils.deprecation import LegacyInstallReasonFailedBdistWheel
32+
from pip._internal.utils.deprecation import (
33+
LegacyInstallReasonFailedBdistWheel,
34+
deprecated,
35+
)
3336
from pip._internal.utils.distutils_args import parse_distutils_args
3437
from pip._internal.utils.filesystem import test_writable_dir
3538
from pip._internal.utils.logging import getLogger
@@ -326,8 +329,6 @@ def run(self, options: Values, args: List[str]) -> int:
326329
target_python=target_python,
327330
ignore_requires_python=options.ignore_requires_python,
328331
)
329-
wheel_cache = WheelCache(options.cache_dir, options.format_control)
330-
331332
build_tracker = self.enter_context(get_build_tracker())
332333

333334
directory = TempDirectory(
@@ -339,6 +340,25 @@ def run(self, options: Values, args: List[str]) -> int:
339340
try:
340341
reqs = self.get_requirements(args, options, finder, session)
341342

343+
if "no-binary-enable-wheel-cache" in options.features_enabled:
344+
# TODO: remove format_control from WheelCache when the deprecation cycle
345+
# is over
346+
wheel_cache = WheelCache(options.cache_dir)
347+
else:
348+
if options.format_control.no_binary:
349+
deprecated(
350+
reason=(
351+
"--no-binary currently disables reading from "
352+
"the cache of locally built wheels. In the future "
353+
"--no-binary will not influence the wheel cache."
354+
),
355+
replacement="to use the --no-cache-dir option",
356+
feature_flag="no-binary-enable-wheel-cache",
357+
issue=11453,
358+
gone_in=None,
359+
)
360+
wheel_cache = WheelCache(options.cache_dir, options.format_control)
361+
342362
# Only when installing is it permitted to use PEP 660.
343363
# In other circumstances (pip wheel, pip download) we generate
344364
# regular (i.e. non editable) metadata and wheels.

src/pip/_internal/commands/wheel.py

+20
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pip._internal.exceptions import CommandError
1212
from pip._internal.operations.build.build_tracker import get_build_tracker
1313
from pip._internal.req.req_install import InstallRequirement
14+
from pip._internal.utils.deprecation import deprecated
1415
from pip._internal.utils.misc import ensure_dir, normalize_path
1516
from pip._internal.utils.temp_dir import TempDirectory
1617
from pip._internal.wheel_builder import build, should_build_for_wheel_command
@@ -120,6 +121,25 @@ def run(self, options: Values, args: List[str]) -> int:
120121

121122
reqs = self.get_requirements(args, options, finder, session)
122123

124+
if "no-binary-enable-wheel-cache" in options.features_enabled:
125+
# TODO: remove format_control from WheelCache when the deprecation cycle
126+
# is over
127+
wheel_cache = WheelCache(options.cache_dir)
128+
else:
129+
if options.format_control.no_binary:
130+
deprecated(
131+
reason=(
132+
"--no-binary currently disables reading from "
133+
"the cache of locally built wheels. In the future "
134+
"--no-binary will not influence the wheel cache."
135+
),
136+
replacement="to use the --no-cache-dir option",
137+
feature_flag="no-binary-enable-wheel-cache",
138+
issue=11453,
139+
gone_in=None,
140+
)
141+
wheel_cache = WheelCache(options.cache_dir, options.format_control)
142+
123143
preparer = self.make_requirement_preparer(
124144
temp_build_dir=directory,
125145
options=options,

0 commit comments

Comments
 (0)