mirror of https://github.com/pypa/pip
Factor out logic for determining resolver to use
This commit is contained in:
parent
8daece5277
commit
385077a944
|
@ -195,7 +195,18 @@ class RequirementCommand(IndexGroupCommand):
|
|||
self.cmd_opts.add_option(cmdoptions.no_clean())
|
||||
|
||||
@staticmethod
|
||||
def determine_resolver_variant(options):
|
||||
# type: (Values) -> str
|
||||
"""Determines which resolver should be used, based on the given options."""
|
||||
if '2020-resolver' in options.features_enabled:
|
||||
resolver_variant = "2020-resolver"
|
||||
else:
|
||||
resolver_variant = "legacy"
|
||||
return resolver_variant
|
||||
|
||||
@classmethod
|
||||
def make_requirement_preparer(
|
||||
cls,
|
||||
temp_build_dir, # type: TempDirectory
|
||||
options, # type: Values
|
||||
req_tracker, # type: RequirementTracker
|
||||
|
@ -211,7 +222,8 @@ class RequirementCommand(IndexGroupCommand):
|
|||
temp_build_dir_path = temp_build_dir.path
|
||||
assert temp_build_dir_path is not None
|
||||
|
||||
if '2020-resolver' in options.features_enabled:
|
||||
resolver_variant = cls.determine_resolver_variant(options)
|
||||
if resolver_variant == "2020-resolver":
|
||||
lazy_wheel = 'fast-deps' in options.features_enabled
|
||||
if lazy_wheel:
|
||||
logger.warning(
|
||||
|
@ -238,8 +250,9 @@ class RequirementCommand(IndexGroupCommand):
|
|||
lazy_wheel=lazy_wheel,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@classmethod
|
||||
def make_resolver(
|
||||
cls,
|
||||
preparer, # type: RequirementPreparer
|
||||
finder, # type: PackageFinder
|
||||
options, # type: Values
|
||||
|
@ -250,7 +263,7 @@ class RequirementCommand(IndexGroupCommand):
|
|||
force_reinstall=False, # type: bool
|
||||
upgrade_strategy="to-satisfy-only", # type: str
|
||||
use_pep517=None, # type: Optional[bool]
|
||||
py_version_info=None # type: Optional[Tuple[int, ...]]
|
||||
py_version_info=None, # type: Optional[Tuple[int, ...]]
|
||||
):
|
||||
# type: (...) -> BaseResolver
|
||||
"""
|
||||
|
@ -261,10 +274,11 @@ class RequirementCommand(IndexGroupCommand):
|
|||
isolated=options.isolated_mode,
|
||||
use_pep517=use_pep517,
|
||||
)
|
||||
resolver_variant = cls.determine_resolver_variant(options)
|
||||
# The long import name and duplicated invocation is needed to convince
|
||||
# Mypy into correctly typechecking. Otherwise it would complain the
|
||||
# "Resolver" class being redefined.
|
||||
if '2020-resolver' in options.features_enabled:
|
||||
if resolver_variant == "2020-resolver":
|
||||
import pip._internal.resolution.resolvelib.resolver
|
||||
|
||||
return pip._internal.resolution.resolvelib.resolver.Resolver(
|
||||
|
|
|
@ -427,7 +427,7 @@ class InstallCommand(RequirementCommand):
|
|||
if conflicts is not None:
|
||||
self._warn_about_conflicts(
|
||||
conflicts,
|
||||
new_resolver='2020-resolver' in options.features_enabled,
|
||||
resolver_variant=self.determine_resolver_variant(options),
|
||||
)
|
||||
|
||||
installed_desc = ' '.join(items)
|
||||
|
@ -520,14 +520,14 @@ class InstallCommand(RequirementCommand):
|
|||
)
|
||||
return None
|
||||
|
||||
def _warn_about_conflicts(self, conflict_details, new_resolver):
|
||||
# type: (ConflictDetails, bool) -> None
|
||||
def _warn_about_conflicts(self, conflict_details, resolver_variant):
|
||||
# type: (ConflictDetails, str) -> None
|
||||
package_set, (missing, conflicting) = conflict_details
|
||||
if not missing and not conflicting:
|
||||
return
|
||||
|
||||
parts = [] # type: List[str]
|
||||
if not new_resolver:
|
||||
if resolver_variant == "legacy":
|
||||
parts.append(
|
||||
"After October 2020 you may experience errors when installing "
|
||||
"or updating packages. This is because pip will change the "
|
||||
|
|
Loading…
Reference in New Issue