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>
bool operator==(const conflict_map<T> &lhs, const conflict_map<T> &rhs)#
template<typename T>
bool operator!=(const conflict_map<T> &lhs, const conflict_map<T> &rhs)#
ProblemsGraph simplify_conflicts(const ProblemsGraph &pbs)#

Hand-crafted hurisitics to simplify conflicts in messy situations.

std::ostream &print_problem_tree_msg(std::ostream &out, const CompressedProblemsGraph &pbs, const ProblemsMessageFormat &format = {})#
std::string problem_tree_msg(const CompressedProblemsGraph &pbs, const ProblemsMessageFormat &format = {})#
template<typename ...Item, typename Func>
void for_each_of(const Request &request, Func &&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)#
const graph_t &graph() const noexcept#
const conflicts_t &conflicts() const noexcept#
node_id root_node() const noexcept#

Public Static Functions

static CompressedProblemsGraph from_problems_graph(const ProblemsGraph &pbs, const merge_criteria_t &merge_criteria = {})#
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)#
const value_type &front() const noexcept#
const value_type &back() const noexcept#
const_iterator begin() const noexcept#
const_iterator end() const noexcept#
const_reverse_iterator rbegin() const noexcept#
const_reverse_iterator rend() const noexcept#
const std::string &name() const#
std::pair<std::string, std::size_t> 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> 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> versions_and_build_strings_trunc(std::string_view sep = "|", std::string_view etc = "...", std::size_t threshold = 5, bool remove_duplicates = true) const#
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

bool operator()(const T &a, const T &b) const#
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)#
bool has_conflict(const key_type &a) const#
const util::flat_set<T> &conflicts(const key_type &a) const#
bool in_conflict(const key_type &a, const key_type &b) const#
const_iterator begin() const noexcept#
const_iterator end() const noexcept#
bool add(const key_type &a, const key_type &b)#
bool remove(const key_type &a, const key_type &b)#
bool remove(const key_type &a)#
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)#
const graph_t &graph() const noexcept#
const conflicts_t &conflicts() const noexcept#
node_id root_node() const noexcept#
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 Functions

bool operator==(const Solution &other) const = default#
inline auto packages() const#

Return a view of all unique packages involved in the solution.

The view is invalidated if actions is modified.

inline auto packages()#
inline auto packages_to_remove() const#

Return a view of all packages that need to be removed.

The view is invalidated if actions is modified.

inline auto packages_to_remove()#
inline auto packages_to_install() const#

Return a view of all packages that need to be installed.

The view is invalidated if actions is modified.

inline auto packages_to_install()#
inline auto packages_to_omit() const#

Return a view of all packages that are omitted.

The view is invalidated if actions is modified.

inline auto packages_to_omit()#

Public Members

action_list actions = {}#

Public Static Attributes

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

Public Functions

bool operator==(const Change &other) const = default#

Public Members

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

Public Functions

bool operator==(const Downgrade &other) const = default#

Public Members

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

Public Functions

bool operator==(const Install &other) const = default#

Public Members

specs::PackageInfo install#
struct Omit#

Public Functions

bool operator==(const Omit &other) const = default#

Public Members

specs::PackageInfo what#
struct Reinstall#

Public Functions

bool operator==(const Reinstall &other) const = default#

Public Members

specs::PackageInfo what#
struct Remove#

Public Functions

bool operator==(const Remove &other) const = default#

Public Members

specs::PackageInfo remove#
struct Upgrade#

Public Functions

bool operator==(const Upgrade &other) const = default#

Public Members

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

Enums

enum class RepodataParser#

Values:

enumerator Mamba#
enumerator Libsolv#
enum class MatchSpecParser#

Values:

enumerator Mixed#
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

bool operator==(const Priorities &lhs, const Priorities &rhs)#
bool operator!=(const Priorities &lhs, const Priorities &rhs)#
bool operator==(const RepodataOrigin &lhs, const RepodataOrigin &rhs)#
bool operator!=(const RepodataOrigin &lhs, const RepodataOrigin &rhs)#
void to_json(nlohmann::json &j, const RepodataOrigin &m)#
void from_json(const nlohmann::json &j, RepodataOrigin &p)#
bool operator==(RepoInfo lhs, RepoInfo rhs)#
bool operator!=(RepoInfo lhs, RepoInfo rhs)#
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 different 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(specs::ChannelResolveParams channel_params, Settings settings)#
Database(const Database&) = delete#
Database(Database&&)#
~Database()#
Database &=delete operator= (const Database &)
Database &operator=(Database&&)#
const specs::ChannelResolveParams &channel_params() const#
const Settings &settings() const#
void set_logger(logger_type callback)#
expected_t<RepoInfo> 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 repo_parser = RepodataParser::Mamba)#
expected_t<RepoInfo> add_repo_from_native_serialization(const fs::u8path &path, const RepodataOrigin &expected, const std::string &channel_id, PipAsPythonDependency add = PipAsPythonDependency::No)#
template<typename Iter>
RepoInfo add_repo_from_packages(Iter first_package, Iter last_package, std::string_view name = "", PipAsPythonDependency add = PipAsPythonDependency::No)#
template<typename Range>
RepoInfo add_repo_from_packages(const Range &packages, std::string_view name = "", PipAsPythonDependency add = PipAsPythonDependency::No)#
expected_t<RepoInfo> native_serialize_repo(const RepoInfo &repo, const fs::u8path &path, const RepodataOrigin &metadata)#
std::optional<RepoInfo> installed_repo() const#
void set_installed_repo(RepoInfo repo)#
void set_repo_priority(RepoInfo repo, Priorities priorities)#
void remove_repo(RepoInfo repo)#
std::size_t repo_count() const#
std::size_t package_count() const#
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 Settings#

Global Database settings.

Public Members

MatchSpecParser matchspec_parser = MatchSpecParser::Libsolv#
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 lightweight description of a repository returned when creating a new repository in the Database. Some modifications to the repo are possible through 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#
RepoInfo &=default operator= (const RepoInfo &)
RepoInfo &=default operator= (RepoInfo &&)
RepoId id() const#
std::string_view name() const#
std::size_t package_count() const#
Priorities priority() const#
class Solver#

Public Types

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

Public Functions

expected_t<Outcome> solve(Database &database, Request &&request, MatchSpecParser ms_parser = MatchSpecParser::Mixed)#
expected_t<Outcome> solve(Database &database, const Request &request, MatchSpecParser ms_parser = MatchSpecParser::Mixed)#
class UnSolvable#

Public Functions

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