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 <hswong3i@pantarei-design.com>
  • Loading branch information
hswong3i committed Nov 17, 2021
1 parent bb63c97 commit 90d04dd
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/docsite/known_good_reqs.txt
Expand Up @@ -9,7 +9,7 @@ docutils==0.16
jinja2==3.0.1
Pygments==2.9.0
PyYAML==5.4.1
resolvelib==0.5.4
resolvelib==0.8.1
rstcheck==3.3.1
sphinx==4.0.2
sphinx-notfound-page==0.7.1 # must be >= 0.6
Expand Down
29 changes: 18 additions & 11 deletions lib/ansible/galaxy/dependency_resolution/providers.py
Expand Up @@ -13,13 +13,6 @@
except ImportError:
TYPE_CHECKING = False

if TYPE_CHECKING:
from typing import Iterable, List, NamedTuple, Optional, Union
from ansible.galaxy.collection.concrete_artifact_manager import (
ConcreteArtifactsManager,
)
from ansible.galaxy.collection.galaxy_api_proxy import MultiGalaxyAPIProxy

from ansible.galaxy.dependency_resolution.dataclasses import (
Candidate,
Requirement,
Expand All @@ -32,6 +25,16 @@

from resolvelib import AbstractProvider

if 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 CollectionDependencyProvider(AbstractProvider):
"""Delegate providing a requirement interface for the resolver."""
Expand Down Expand Up @@ -126,9 +129,11 @@ def identify(self, requirement_or_candidate):

def get_preference(
self, # type: CollectionDependencyProvider
resolution, # type: Optional[Candidate]
candidates, # type: List[Candidate]
information, # type: List[NamedTuple]
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.
Expand Down Expand Up @@ -173,6 +178,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 @@ -182,7 +188,7 @@ def get_preference(
return float('-inf')
return len(candidates)

def find_matches(self, requirements):
def find_matches(self, identifier, requirements, incompatibilities):
# type: (List[Requirement]) -> List[Candidate]
r"""Find all possible candidates satisfying given requirements.
Expand All @@ -208,6 +214,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
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
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.txt
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.txt
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 90d04dd

Please sign in to comment.