From 9d6ed2de53adc8c98449c53927008e2aa93d58a8 Mon Sep 17 00:00:00 2001 From: Wong Hoi Sing Edison Date: Tue, 9 Nov 2021 15:13:19 +0800 Subject: [PATCH] Upgrade `resolvelib>=0.8.1,<0.9.0` Since 2021-09-27 `resolvelib` author comment with "issue resolved now" (see https://github.com/sarugaku/resolvelib/issues/69#issuecomment-927333533). Replace `resolvelib` version upper cap with `resolvelib>=0.8.1,<0.9.0` with corresponding `find_matches()` and `get_preference()` interface change should now be good enough. Signed-off-by: Wong Hoi Sing Edison --- .../galaxy/dependency_resolution/providers.py | 32 ++++++++++++------- requirements.txt | 2 +- .../_data/requirements/ansible.txt | 2 +- .../code-smell/docs-build.requirements.in | 2 +- .../code-smell/docs-build.requirements.txt | 2 +- .../code-smell/package-data.requirements.in | 2 +- .../code-smell/package-data.requirements.txt | 2 +- 7 files changed, 26 insertions(+), 18 deletions(-) diff --git a/lib/ansible/galaxy/dependency_resolution/providers.py b/lib/ansible/galaxy/dependency_resolution/providers.py index 9d82513c2686b6..ac8fcebd6af72c 100644 --- a/lib/ansible/galaxy/dependency_resolution/providers.py +++ b/lib/ansible/galaxy/dependency_resolution/providers.py @@ -9,12 +9,6 @@ import functools import typing as t -if t.TYPE_CHECKING: - from ansible.galaxy.collection.concrete_artifact_manager import ( - ConcreteArtifactsManager, - ) - from ansible.galaxy.collection.galaxy_api_proxy import MultiGalaxyAPIProxy - from ansible.galaxy.collection.gpg import get_signature_from_source from ansible.galaxy.dependency_resolution.dataclasses import ( Candidate, @@ -30,6 +24,16 @@ from collections.abc import Set from resolvelib import AbstractProvider +if t.TYPE_CHECKING: + from typing import Iterable, Iterator, List, Mapping, Sequence, Union + from ansible.galaxy.collection.concrete_artifact_manager import ( + ConcreteArtifactsManager, + ) + from ansible.galaxy.collection.galaxy_api_proxy import MultiGalaxyAPIProxy + from resolvelib.providers import Preference + from resolvelib.resolvers import RequirementInformation + PreferenceInformation = RequirementInformation[Requirement, Candidate] + class PinnedCandidateRequests(Set): """Custom set class to store Candidate objects. Excludes the 'signatures' attribute when determining if a Candidate instance is in the set.""" @@ -168,10 +172,12 @@ def identify(self, requirement_or_candidate): def get_preference( self, # type: CollectionDependencyProvider - resolution, # type: t.Optional[Candidate] - candidates, # type: list[Candidate] - information, # type: list[t.NamedTuple] - ): # type: (...) -> t.Union[float, int] + identifier, # type: str + resolutions, # type: Mapping[str, Candidate] + candidates, # type: Mapping[str, Iterator[Candidate]] + information, # type: Mapping[str, Iterable[PreferenceInformation]] + backtrack_causes, # type: Sequence[PreferenceInformation] + ): # type: (...) -> Union[float, int] """Return sort key function return value for given requirement. This result should be based on preference that is defined as @@ -215,6 +221,7 @@ def get_preference( the value is, the more preferred this requirement is (i.e. the sorting function is called with ``reverse=False``). """ + candidates = list(candidates[identifier]) if any( candidate in self._preferred_candidates for candidate in candidates @@ -224,8 +231,8 @@ def get_preference( return float('-inf') return len(candidates) - def find_matches(self, requirements): - # type: (list[Requirement]) -> list[Candidate] + def find_matches(self, identifier, requirements, incompatibilities): + # type: (List[Requirement]) -> List[Candidate] r"""Find all possible candidates satisfying given requirements. This tries to get candidates based on the requirements' types. @@ -250,6 +257,7 @@ def find_matches(self, requirements): # FIXME: its cloned tmp dir. Using only the first one creates # FIXME: loops that prevent any further dependency exploration. # FIXME: We need to figure out how to prevent this. + requirements = list(requirements[identifier]) first_req = requirements[0] fqcn = first_req.fqcn # The fqcn is guaranteed to be the same diff --git a/requirements.txt b/requirements.txt index a732a5951d2190..ddc114e23b0210 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,4 @@ packaging # NOTE: resolvelib 0.x version bumps should be considered major/breaking # NOTE: and we should update the upper cap with care, at least until 1.0 # NOTE: Ref: https://github.com/sarugaku/resolvelib/issues/69 -resolvelib >= 0.5.3, < 0.6.0 # dependency resolver used by ansible-galaxy +resolvelib >= 0.8.1, < 0.9.0 # dependency resolver used by ansible-galaxy diff --git a/test/lib/ansible_test/_data/requirements/ansible.txt b/test/lib/ansible_test/_data/requirements/ansible.txt index a732a5951d2190..ddc114e23b0210 100644 --- a/test/lib/ansible_test/_data/requirements/ansible.txt +++ b/test/lib/ansible_test/_data/requirements/ansible.txt @@ -10,4 +10,4 @@ packaging # NOTE: resolvelib 0.x version bumps should be considered major/breaking # NOTE: and we should update the upper cap with care, at least until 1.0 # NOTE: Ref: https://github.com/sarugaku/resolvelib/issues/69 -resolvelib >= 0.5.3, < 0.6.0 # dependency resolver used by ansible-galaxy +resolvelib >= 0.8.1, < 0.9.0 # dependency resolver used by ansible-galaxy diff --git a/test/sanity/code-smell/docs-build.requirements.in b/test/sanity/code-smell/docs-build.requirements.in index f4f8c9b01faaac..49e561ae56cf74 100644 --- a/test/sanity/code-smell/docs-build.requirements.in +++ b/test/sanity/code-smell/docs-build.requirements.in @@ -1,6 +1,6 @@ jinja2 pyyaml -resolvelib < 0.6.0 +resolvelib >= 0.8.1, < 0.9.0 sphinx == 4.2.0 sphinx-notfound-page sphinx-ansible-theme diff --git a/test/sanity/code-smell/docs-build.requirements.txt b/test/sanity/code-smell/docs-build.requirements.txt index 6f3dc29121f1f1..05ec733ee7df8c 100644 --- a/test/sanity/code-smell/docs-build.requirements.txt +++ b/test/sanity/code-smell/docs-build.requirements.txt @@ -27,7 +27,7 @@ pyparsing==2.4.7 pytz==2021.3 PyYAML==6.0 requests==2.26.0 -resolvelib==0.5.4 +resolvelib==0.8.1 rstcheck==3.3.1 semantic-version==2.8.5 sh==1.14.2 diff --git a/test/sanity/code-smell/package-data.requirements.in b/test/sanity/code-smell/package-data.requirements.in index 68c2248e58163d..a3c72b7f69480e 100644 --- a/test/sanity/code-smell/package-data.requirements.in +++ b/test/sanity/code-smell/package-data.requirements.in @@ -1,7 +1,7 @@ docutils < 0.18 # match version required by sphinx in the docs-build sanity test jinja2 pyyaml # ansible-core requirement -resolvelib < 0.6.0 +resolvelib >= 0.8.1, < 0.9.0 rstcheck straight.plugin antsibull-changelog diff --git a/test/sanity/code-smell/package-data.requirements.txt b/test/sanity/code-smell/package-data.requirements.txt index c3caa7fcdcb88a..85a996a97e53a8 100644 --- a/test/sanity/code-smell/package-data.requirements.txt +++ b/test/sanity/code-smell/package-data.requirements.txt @@ -6,7 +6,7 @@ MarkupSafe==2.0.1 packaging==21.2 pyparsing==2.4.7 PyYAML==6.0 -resolvelib==0.5.4 +resolvelib==0.8.1 rstcheck==3.3.1 semantic-version==2.8.5 straight.plugin==1.5.0