Merge master

This commit is contained in:
Tzu-ping Chung 2020-12-12 18:49:14 +08:00
commit d869e0cbfd
4 changed files with 23 additions and 3 deletions

2
news/9117.bugfix.rst Normal file
View File

@ -0,0 +1,2 @@
New resolver: The "Requirement already satisfied" log is not printed only once
for each package during resolution.

1
news/9249.feature.rst Normal file
View File

@ -0,0 +1 @@
Add a mechanism to delay resolving certain packages, and use it for setuptools.

View File

@ -97,9 +97,11 @@ class Factory(object):
self._force_reinstall = force_reinstall
self._ignore_requires_python = ignore_requires_python
self._build_failures = {} # type: Cache[InstallationError]
self._link_candidate_cache = {} # type: Cache[LinkCandidate]
self._editable_candidate_cache = {} # type: Cache[EditableCandidate]
self._build_failures = {} # type: Cache[InstallationError]
self._installed_candidate_cache = {
} # type: Dict[str, AlreadyInstalledCandidate]
if not ignore_installed:
self._installed_dists = {
@ -121,7 +123,11 @@ class Factory(object):
template, # type: InstallRequirement
):
# type: (...) -> Candidate
base = AlreadyInstalledCandidate(dist, template, factory=self)
try:
base = self._installed_candidate_cache[dist.key]
except KeyError:
base = AlreadyInstalledCandidate(dist, template, factory=self)
self._installed_candidate_cache[dist.key] = base
if extras:
return ExtrasCandidate(base, extras)
return base

View File

@ -117,7 +117,18 @@ class PipProvider(AbstractProvider):
restrictive = _get_restrictive_rating(req for req, _ in information)
transitive = all(parent is not None for _, parent in information)
key = next(iter(candidates)).name if candidates else ""
return (restrictive, transitive, key)
# HACK: Setuptools have a very long and solid backward compatibility
# track record, and extremely few projects would request a narrow,
# non-recent version range of it since that would break a lot things.
# (Most projects specify it only to request for an installer feature,
# which does not work, but that's another topic.) Intentionally
# delaying Setuptools helps reduce branches the resolver has to check.
# This serves as a temporary fix for issues like "apache-airlfow[all]"
# while we work on "proper" branch pruning techniques.
delay_this = (key == "setuptools")
return (delay_this, restrictive, transitive, key)
def find_matches(self, requirements):
# type: (Sequence[Requirement]) -> Iterable[Candidate]