mamba::solver

mamba::solver#

The mamba::solver namespace contains the packages solver and related objects. This particular namespace is a generic common interface, while the subnamespace mamba::solver::libsolv contains LibSolv specific implementations.

namespace solver#

Functions

template<typename T>
auto operator==(const conflict_map<T> &lhs, const conflict_map<T> &rhs) -> bool#
template<typename T>
auto operator!=(const conflict_map<T> &lhs, const conflict_map<T> &rhs) -> bool#
auto simplify_conflicts(const ProblemsGraph &pbs) -> ProblemsGraph#

Hand-crafted hurisitics to simplify conflicts in messy situations.

auto print_problem_tree_msg(std::ostream &out, const CompressedProblemsGraph &pbs, const ProblemsMessageFormat &format = {}) -> std::ostream&#
auto problem_tree_msg(const CompressedProblemsGraph &pbs, const ProblemsMessageFormat &format = {}) -> std::string#
template<typename ...Item, typename Func>
void for_each_of(const Request &request, Func &&func)#
template<typename Iter, typename UnaryFunc>
void for_each_to_remove(Iter first, Iter last, UnaryFunc &&func)#
template<typename Range, typename UnaryFunc>
void for_each_to_remove(Range &&actions, UnaryFunc &&func)#
template<typename Iter, typename UnaryFunc>
void for_each_to_install(Iter first, Iter last, UnaryFunc &&func)#
template<typename Range, typename UnaryFunc>
void for_each_to_install(Range &&actions, UnaryFunc &&func)#
template<typename Iter, typename UnaryFunc>
void for_each_to_omit(Iter first, Iter last, UnaryFunc &&func)#
template<typename Range, typename UnaryFunc>
void for_each_to_omit(Range &&actions, UnaryFunc &&func)#
class CompressedProblemsGraph#

Public Types

using RootNode = ProblemsGraph::RootNode#
using PackageListNode = NamedList<ProblemsGraph::PackageNode>#
using UnresolvedDependencyListNode = NamedList<ProblemsGraph::UnresolvedDependencyNode>#
using ConstraintListNode = NamedList<ProblemsGraph::ConstraintNode>#
using node_t = std::variant<RootNode, PackageListNode, UnresolvedDependencyListNode, ConstraintListNode>#
using edge_t = NamedList<specs::MatchSpec>#
using graph_t = util::DiGraph<node_t, edge_t>#
using node_id = graph_t::node_id#
using conflicts_t = conflict_map<node_id>#
using merge_criteria_t = std::function<bool(const ProblemsGraph&, ProblemsGraph::node_id, ProblemsGraph::node_id)>#

Public Functions

CompressedProblemsGraph(graph_t graph, conflicts_t conflicts, node_id root_node)#
auto graph() const noexcept -> const graph_t&#
auto conflicts() const noexcept -> const conflicts_t&#
auto root_node() const noexcept -> node_id#

Public Static Functions

static auto from_problems_graph(const ProblemsGraph &pbs, const merge_criteria_t &merge_criteria = {}) -> CompressedProblemsGraph#
template<typename T, typename Allocator = std::allocator<T>>
class NamedList : private mamba::util::flat_set<T, RoughCompare<T>, std::allocator<T>>#

A list of objects with a name, version, and build member.

For simplicity, the implementation is kept in the translation unit with specialization for needed types.

Public Types

using Base = util::flat_set<T, RoughCompare<T>, Allocator>#

Public Functions

NamedList() = default#
template<typename InputIterator>
NamedList(InputIterator first, InputIterator last)#
auto front() const noexcept -> const value_type&#
auto back() const noexcept -> const value_type&#
auto begin() const noexcept -> const_iterator#
auto end() const noexcept -> const_iterator#
auto rbegin() const noexcept -> const_reverse_iterator#
auto rend() const noexcept -> const_reverse_iterator#
auto name() const -> const std::string&#
auto versions_trunc(std::string_view sep = "|", std::string_view etc = "...", std::size_t threshold = 5, bool remove_duplicates = true) const -> std::pair<std::string, std::size_t>#
auto build_strings_trunc(std::string_view sep = "|", std::string_view etc = "...", std::size_t threshold = 5, bool remove_duplicates = true) const -> std::pair<std::string, std::size_t>#
auto versions_and_build_strings_trunc(std::string_view sep = "|", std::string_view etc = "...", std::size_t threshold = 5, bool remove_duplicates = true) const -> std::pair<std::string, std::size_t>#
void insert(const value_type &e)#
void insert(value_type &&e)#
template<typename InputIterator>
void insert(InputIterator first, InputIterator last)#
template<typename T>
struct RoughCompare#

A rough comparison for nodes.

We need to be able to compare nodes for using them in a set but we do not have proper version parsing. Ideally we would like proper comparison for printing packages in order.

As with NamedList below, the implementation is currently kept private for needed types.

Public Functions

auto operator()(const T &a, const T &b) const -> bool#
template<typename T>
class conflict_map : private std::unordered_map<T, util::flat_set<T>>#

Public Types

using Base = std::unordered_map<T, util::flat_set<T>>#

Public Functions

conflict_map() = default#
conflict_map(std::initializer_list<std::pair<T, T>> conflicts_pairs)#
auto has_conflict(const key_type &a) const -> bool#
auto conflicts(const key_type &a) const -> const util::flat_set<T>&#
auto in_conflict(const key_type &a, const key_type &b) const -> bool#
auto begin() const noexcept -> const_iterator#
auto end() const noexcept -> const_iterator#
auto add(const key_type &a, const key_type &b) -> bool#
auto remove(const key_type &a, const key_type &b) -> bool#
auto remove(const key_type &a) -> bool#
class ProblemsGraph#

A directed graph of the packages involved in a libsolv conflict.

Public Types

using node_t = std::variant<RootNode, PackageNode, UnresolvedDependencyNode, ConstraintNode>#
using edge_t = specs::MatchSpec#
using graph_t = util::DiGraph<node_t, edge_t>#
using node_id = graph_t::node_id#
using conflicts_t = conflict_map<node_id>#

Public Functions

ProblemsGraph(graph_t graph, conflicts_t conflicts, node_id root_node)#
auto graph() const noexcept -> const graph_t&#
auto conflicts() const noexcept -> const conflicts_t&#
auto root_node() const noexcept -> node_id#
struct ConstraintNode : public mamba::specs::MatchSpec#
struct PackageNode : public mamba::specs::PackageInfo#
struct RootNode#
struct UnresolvedDependencyNode : public mamba::specs::MatchSpec#
struct ProblemsMessageFormat#

Formatting options for error message functions.

Public Members

fmt::text_style unavailable = fmt::fg(fmt::terminal_color::red)#
fmt::text_style available = fmt::fg(fmt::terminal_color::green)#
std::array<std::string_view, 4> indents = {"│  ", "   ", "├─ ", "└─ "}#
struct Request#

Public Types

using Job = std::variant<Install, Remove, Update, UpdateAll, Keep, Freeze, Pin>#
using job_list = std::vector<Job>#

Public Members

Flags flags = {}#
job_list jobs = {}#
struct Flags#

Public Members

bool keep_dependencies = true#

Keep the dependencies of the install package in the solution.

bool keep_user_specs = true#

Keep the original user requested package in the solution.

bool force_reinstall = false#

Force reinstallation of jobs.

bool allow_downgrade = true#

Allow downgrading packages to satisfy requirements.

bool allow_uninstall = true#

Allow uninstalling packages to satisfy requirements.

bool strict_repo_priority = true#

Prefer packages by repoitory order.

bool order_request = true#

Order the request to get a deterministic solution.

struct Freeze#

Instruct to freeze the version and status of the matching installed package.

Public Members

specs::MatchSpec spec#
struct Install#

Instruct to install a package matching the given spec.

Public Members

specs::MatchSpec spec#
struct Keep#

Instruct to keep packages matching the spec during dependency clean.

Public Members

specs::MatchSpec spec#
struct Pin#

Add a constraints on packages possible to install.

Public Members

specs::MatchSpec spec#
struct Remove#

Instruct to remove packages matching the given spec.

Public Members

specs::MatchSpec spec#
bool clean_dependencies = true#
struct Update#

Instruct to update packages matching the given spec.

Public Members

specs::MatchSpec spec#
bool clean_dependencies = true#
struct UpdateAll#

Instruct to update all installed packages.

Public Members

bool clean_dependencies = true#
struct Solution#

Public Types

using Action = std::variant<Omit, Upgrade, Downgrade, Change, Reinstall, Remove, Install>#
using action_list = std::vector<Action>#

Public Members

action_list actions = {}#

Public Static Attributes

template<typename T>
static constexpr bool has_remove_v = util::is_any_of_v<T, Upgrade, Downgrade, Change, Remove>#
template<typename T>
static constexpr bool has_install_v = util::is_any_of_v<T, Upgrade, Downgrade, Change, Install>#
struct Change#

Public Members

specs::PackageInfo remove#
specs::PackageInfo install#
struct Downgrade#

Public Members

specs::PackageInfo remove#
specs::PackageInfo install#
struct Install#

Public Members

specs::PackageInfo install#
struct Omit#

Public Members

specs::PackageInfo what#
struct Reinstall#

Public Members

specs::PackageInfo what#
struct Remove#

Public Members

specs::PackageInfo remove#
struct Upgrade#

Public Members

specs::PackageInfo remove#
specs::PackageInfo install#
namespace libsolv#

Enums

enum class RepodataParser#

Values:

enumerator Mamba#
enumerator Libsolv#
enum class PipAsPythonDependency : bool#

Values:

enumerator No#
enumerator Yes#
enum class PackageTypes#

Values:

enumerator CondaOnly#
enumerator TarBz2Only#
enumerator CondaAndTarBz2#
enumerator CondaOrElseTarBz2#
enum class VerifyPackages : bool#

Values:

enumerator No#
enumerator Yes#
enum class LogLevel#

Values:

enumerator Debug#
enumerator Warning#
enumerator Error#
enumerator Fatal#

Functions

auto operator==(const Priorities &lhs, const Priorities &rhs) -> bool#
auto operator!=(const Priorities &lhs, const Priorities &rhs) -> bool#
auto operator==(const RepodataOrigin &lhs, const RepodataOrigin &rhs) -> bool#
auto operator!=(const RepodataOrigin &lhs, const RepodataOrigin &rhs) -> bool#
void to_json(nlohmann::json &j, const RepodataOrigin &m)#
void from_json(const nlohmann::json &j, RepodataOrigin &p)#
auto operator==(RepoInfo lhs, RepoInfo rhs) -> bool#
auto operator!=(RepoInfo lhs, RepoInfo rhs) -> bool#
class Database#

Database of solvable involved in resolving en environment.

The database contains the solvable (packages) information required from the Solver. The database can be reused by multiple solvers to solve differents requirements with the same ecosystem.

Public Types

using logger_type = std::function<void(LogLevel, std::string_view)>#

Public Functions

explicit Database(specs::ChannelResolveParams channel_params)#
Database(const Database&) = delete#
Database(Database&&)#
~Database()#
auto operator=(const Database&) -> Database& = delete#
auto operator=(Database&&) -> Database&#
auto channel_params() const -> const specs::ChannelResolveParams&#
void set_logger(logger_type callback)#
auto add_repo_from_repodata_json(const fs::u8path &path, std::string_view url, const std::string &channel_id, PipAsPythonDependency add = PipAsPythonDependency::No, PackageTypes package_types = PackageTypes::CondaOrElseTarBz2, VerifyPackages verify_packages = VerifyPackages::No, RepodataParser parser = RepodataParser::Mamba) -> expected_t<RepoInfo>#
auto add_repo_from_native_serialization(const fs::u8path &path, const RepodataOrigin &expected, const std::string &channel_id, PipAsPythonDependency add = PipAsPythonDependency::No) -> expected_t<RepoInfo>#
template<typename Iter>
auto add_repo_from_packages(Iter first_package, Iter last_package, std::string_view name = "", PipAsPythonDependency add = PipAsPythonDependency::No) -> RepoInfo#
template<typename Range>
auto add_repo_from_packages(const Range &packages, std::string_view name = "", PipAsPythonDependency add = PipAsPythonDependency::No) -> RepoInfo#
auto native_serialize_repo(const RepoInfo &repo, const fs::u8path &path, const RepodataOrigin &metadata) -> expected_t<RepoInfo>#
auto installed_repo() const -> std::optional<RepoInfo>#
void set_installed_repo(RepoInfo repo)#
void set_repo_priority(RepoInfo repo, Priorities priorities)#
void remove_repo(RepoInfo repo)#
auto repo_count() const -> std::size_t#
auto package_count() const -> std::size_t#
template<typename Func>
void for_each_package_in_repo(RepoInfo repo, Func&&) const#
template<typename Func>
void for_each_package_matching(const specs::MatchSpec &ms, Func&&)#
template<typename Func>
void for_each_package_depending_on(const specs::MatchSpec &ms, Func&&)#
class Impl#

An access control wrapper.

This struct is to control who can access the underlying private representation of the ObjPool without giving them full friend access.

struct Priorities#

Public Types

using value_type = int#

Public Members

value_type priority = 0#
value_type subpriority = 0#
struct RepodataOrigin#

Metadata serialized with a repository index.

This is used to identify if the binary serialization is out of date with the expected index.

Public Members

std::string url = {}#
std::string etag = {}#
std::string mod = {}#
class RepoInfo#

A libsolv repository descriptor.

In libsolv, most of the data is help in the Database, and repo are tightly coupled with them. This repository class is a lightwight description of a repository returned when creating a new repository in the Database. Some modifications to the repo are possible throught the Database.

See also

Database::add_repo_from_repodata_json

See also

Database::add_repo_from_packages

See also

Database::remove_repo

Public Types

using RepoId = int#

Public Functions

RepoInfo(const RepoInfo&) = default#
RepoInfo(RepoInfo&&) = default#
auto operator=(const RepoInfo&) -> RepoInfo& = default#
auto operator=(RepoInfo&&) -> RepoInfo& = default#
auto id() const -> RepoId#
auto name() const -> std::string_view#
auto package_count() const -> std::size_t#
auto priority() const -> Priorities#
class Solver#

Public Types

using Outcome = std::variant<Solution, UnSolvable>#

Public Functions

auto solve(Database &pool, Request &&request) -> expected_t<Outcome>#
auto solve(Database &pool, const Request &request) -> expected_t<Outcome>#
class UnSolvable#

Public Functions

UnSolvable(UnSolvable&&)#
~UnSolvable()#
auto operator=(UnSolvable&&) -> UnSolvable&#
auto problems(Database &pool) const -> std::vector<std::string>#
auto problems_to_str(Database &pool) const -> std::string#
auto all_problems_to_str(Database &pool) const -> std::string#
auto problems_graph(const Database &pool) const -> ProblemsGraph#
auto explain_problems_to(Database &pool, std::ostream &out, const ProblemsMessageFormat &format) const -> std::ostream&#
auto explain_problems(Database &pool, const ProblemsMessageFormat &format) const -> std::string#