Skip to content

Commit 98455c2

Browse files
committed
Opt-in lazy wheel as a --use-feature
By invoking pip with --use-feature=lazy-wheel, the new resolver will try to obtain dependency information by lazily download wheels by HTTP range requests.
1 parent 4bb29ac commit 98455c2

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

src/pip/_internal/cli/cmdoptions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ def check_list_path_option(options):
916916
metavar='feature',
917917
action='append',
918918
default=[],
919-
choices=['2020-resolver'],
919+
choices=['2020-resolver', 'lazy-wheel'],
920920
help='Enable new functionality, that may be backward incompatible.',
921921
) # type: Callable[..., Option]
922922

src/pip/_internal/cli/req_command.py

+1
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def make_resolver(
273273
force_reinstall=force_reinstall,
274274
upgrade_strategy=upgrade_strategy,
275275
py_version_info=py_version_info,
276+
lazy_wheel='lazy-wheel' in options.features_enabled,
276277
)
277278
import pip._internal.resolution.legacy.resolver
278279
return pip._internal.resolution.legacy.resolver.Resolver(

src/pip/_internal/resolution/resolvelib/candidates.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,11 @@ def __init__(
302302
def iter_dependencies(self):
303303
# type: () -> Iterable[Optional[Requirement]]
304304
dist = None # type: Optional[Distribution]
305-
preparer, req = self._factory.preparer, self._ireq
305+
preparer, lazy_wheel = self._factory.preparer, self._factory.lazy_wheel
306306
remote_wheel = self._link.is_wheel and not self._link.is_file
307-
# TODO: Opt-in as unstable feature.
308-
if remote_wheel and not preparer.require_hashes:
307+
if lazy_wheel and remote_wheel and not preparer.require_hashes:
309308
assert self._name is not None
310-
logger.info('Collecting %s', req.req or req)
309+
logger.info('Collecting %s', self._ireq.req or self._ireq)
311310
# If RuntimeError is raised, fallback to self.dist.
312311
with indent_log(), suppress(RuntimeError):
313312
logger.info(

src/pip/_internal/resolution/resolvelib/factory.py

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def __init__(
8282
ignore_installed, # type: bool
8383
ignore_requires_python, # type: bool
8484
py_version_info=None, # type: Optional[Tuple[int, ...]]
85+
lazy_wheel=False, # type: bool
8586
):
8687
# type: (...) -> None
8788

@@ -93,6 +94,7 @@ def __init__(
9394
self._use_user_site = use_user_site
9495
self._force_reinstall = force_reinstall
9596
self._ignore_requires_python = ignore_requires_python
97+
self.lazy_wheel = lazy_wheel
9698

9799
self._link_candidate_cache = {} # type: Cache[LinkCandidate]
98100
self._editable_candidate_cache = {} # type: Cache[EditableCandidate]

src/pip/_internal/resolution/resolvelib/resolver.py

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __init__(
4848
force_reinstall, # type: bool
4949
upgrade_strategy, # type: str
5050
py_version_info=None, # type: Optional[Tuple[int, ...]]
51+
lazy_wheel=False, # type: bool
5152
):
5253
super(Resolver, self).__init__()
5354

@@ -63,6 +64,7 @@ def __init__(
6364
ignore_installed=ignore_installed,
6465
ignore_requires_python=ignore_requires_python,
6566
py_version_info=py_version_info,
67+
lazy_wheel=lazy_wheel,
6668
)
6769
self.ignore_dependencies = ignore_dependencies
6870
self.upgrade_strategy = upgrade_strategy

0 commit comments

Comments
 (0)