Skip to content

Commit

Permalink
Upgrade resolvelib>=0.8.1,<0.9.0
Browse files Browse the repository at this point in the history
Since 2021-09-27 `resolvelib` author comment with "issue resolved now"
(see sarugaku/resolvelib#69 (comment)).

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 <[email protected]>
  • Loading branch information
hswong3i committed May 17, 2022
1 parent 1e3cf9f commit ead46fd
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 19 deletions.
33 changes: 20 additions & 13 deletions lib/ansible/galaxy/dependency_resolution/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +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,
Requirement,
Expand All @@ -30,6 +23,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."""
Expand Down Expand Up @@ -168,10 +171,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
Expand Down Expand Up @@ -215,6 +220,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
Expand All @@ -224,8 +230,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.
Expand All @@ -250,6 +256,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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/lib/ansible_test/_data/requirements/ansible.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/sanity/code-smell/docs-build.requirements.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/sanity/code-smell/docs-build.requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/sanity/code-smell/package-data.requirements.in
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion test/sanity/code-smell/package-data.requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ead46fd

Please sign in to comment.