Debian Codegraph @

lib/ansible/galaxy/dependency_resolution/__init__.py

raw
1 # -*- coding: utf-8 -*-
2 # Copyright: (c) 2020-2021, Ansible Project
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4 """Dependency resolution machinery."""
5
6 from __future__ import annotations
7
8 import collections.abc as _c
9 import typing as t
10
11 if t.TYPE_CHECKING:
12 from ansible.galaxy.api import GalaxyAPI
13 from ansible.galaxy.collection.concrete_artifact_manager import (
14 ConcreteArtifactsManager,
15 )
16 from ansible.galaxy.dependency_resolution.dataclasses import Candidate
17
18 from ansible.galaxy.collection.galaxy_api_proxy import MultiGalaxyAPIProxy
19 from ansible.galaxy.dependency_resolution.providers import CollectionDependencyProvider
20 from ansible.galaxy.dependency_resolution.reporters import CollectionDependencyReporter
21 from ansible.galaxy.dependency_resolution.resolvers import CollectionDependencyResolver
22
23
24 def build_collection_dependency_resolver(
25 galaxy_apis: _c.Iterable[GalaxyAPI],
26 concrete_artifacts_manager: ConcreteArtifactsManager,
27 preferred_candidates: _c.Iterable[Candidate] | None = None,
28 with_deps: bool = True,
29 with_pre_releases: bool = False,
30 upgrade: bool = False,
31 include_signatures: bool = True,
32 offline: bool = False,
33 ) -> CollectionDependencyResolver:
34 """Return a collection dependency resolver.
35
36 The returned instance will have a ``resolve()`` method for
37 further consumption.
38 """
39 return CollectionDependencyResolver(
40 CollectionDependencyProvider(
41 apis=MultiGalaxyAPIProxy(galaxy_apis, concrete_artifacts_manager, offline=offline),
42 concrete_artifacts_manager=concrete_artifacts_manager,
43 preferred_candidates=preferred_candidates,
44 with_deps=with_deps,
45 with_pre_releases=with_pre_releases,
46 upgrade=upgrade,
47 include_signatures=include_signatures,
48 ),
49 CollectionDependencyReporter(),
50 )