Skip to content

Commit d718192

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 a073856 commit d718192

File tree

6 files changed

+12
-5
lines changed

6 files changed

+12
-5
lines changed

news/8532.feature

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Allow the new resolver to obtain dependency information through wheels
2+
lazily downloaded using HTTP range requests. To enable this feature,
3+
invoke ``pip`` with ``--use-feature=lazy-wheel``.

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
@@ -271,6 +271,7 @@ def make_resolver(
271271
force_reinstall=force_reinstall,
272272
upgrade_strategy=upgrade_strategy,
273273
py_version_info=py_version_info,
274+
lazy_wheel='lazy-wheel' in options.features_enabled,
274275
)
275276
import pip._internal.resolution.legacy.resolver
276277
return pip._internal.resolution.legacy.resolver.Resolver(

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,11 @@ def __init__(
304304
def iter_dependencies(self):
305305
# type: () -> Iterable[Optional[Requirement]]
306306
dist = None # type: Optional[Distribution]
307-
preparer, req = self._factory.preparer, self._ireq
307+
preparer, lazy_wheel = self._factory.preparer, self._factory.lazy_wheel
308308
remote_wheel = self._link.is_wheel and not self._link.is_file
309-
# TODO: Opt-in as unstable feature.
310-
if remote_wheel and not preparer.require_hashes:
309+
if lazy_wheel and remote_wheel and not preparer.require_hashes:
311310
assert self._name is not None
312-
logger.info('Collecting %s', req.req or req)
311+
logger.info('Collecting %s', self._ireq.req or self._ireq)
313312
# If RuntimeError is raised, fallback to self.dist.
314313
with indent_log(), suppress(RuntimeError):
315314
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
self._finder = finder
@@ -92,6 +93,7 @@ def __init__(
9293
self._use_user_site = use_user_site
9394
self._force_reinstall = force_reinstall
9495
self._ignore_requires_python = ignore_requires_python
96+
self.lazy_wheel = lazy_wheel
9597

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

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

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

@@ -64,6 +65,7 @@ def __init__(
6465
ignore_installed=ignore_installed,
6566
ignore_requires_python=ignore_requires_python,
6667
py_version_info=py_version_info,
68+
lazy_wheel=lazy_wheel,
6769
)
6870
self.ignore_dependencies = ignore_dependencies
6971
self.upgrade_strategy = upgrade_strategy

0 commit comments

Comments
 (0)