mamba::specs

mamba::specs#

The mamba::specs namespace contains object to describe abstraction in the Conda ecosystem. They are purely functional and do not have any observable impact on the user system.

namespace specs#

Typedefs

using AuthenticationInfo = std::variant<BasicHTTPAuthentication, BearerToken, CondaToken>#
using AuthenticationDataBase = util::weakening_map<std::unordered_map<std::string, AuthenticationInfo>, URLWeakener>#

A class that holds the authentication info stored by users.

Essentially a map, except that some keys can match mutliple queries. For instance “mamba.org/private” should be matched by queries “mamba.org/private”, “mamba.org/private/channel”, but not “mamba.org/public”.

A best effort is made to satifiy this with xxx_compatible.

Future development of this class should aim to replace the map and keys with a AuthenticationSpec, that can decide whether or not a URL should benefit from such its authentication. Possibly, a string reprensentation such as “*.mamba.org/private/channel*” could be added to parse users intentions, rather than relying on the assumptions made here.

template<typename T>
using expected_parse_t = tl::expected<T, ParseError>#
using DynamicPlatform = std::string#
using VersionPart = std::vector<VersionPartAtom>#

A sequence of VersionPartAtom meant to represent a part of a version (e.g.

major, minor).

Version parts can have a arbitrary number of atoms, such as {0, “post”} {1, “dev”} in 0post1dev

Todo:

Use a small vector of expected size 1 if performance ar not good enough.

See also

Version::parse for how this is computed from strings.

using CommonVersion = std::vector<VersionPart>#

A sequence of VersionPart meant to represent all parts of a version.

CommonVersion are composed of an aribtrary postive number parts, such as major, minor. They are typically separated by dots, for instance the three parts in 3.0post1dev.4 are {{3, “”}}, {{0, “post”}, {1, “dev”}}, and {{4, “”}}.

Todo:

Use a small vector of expected size 4 if performance ar not good enough.

See also

Version::parse for how this is computed from strings.

Enums

enum class PackageType#

Values:

enumerator Unknown#
enumerator Conda#
enumerator Wheel#
enum class KnownPlatform#

All platforms known to Conda.

When one platform name is the substring of another, the longest appears first so that it makes it easier to use in a parser.

Values:

enumerator noarch#
enumerator linux_32#
enumerator linux_64#
enumerator linux_armv6l#
enumerator linux_armv7l#
enumerator linux_aarch64#
enumerator linux_ppc64le#
enumerator linux_ppc64#
enumerator linux_s390x#
enumerator linux_riscv32#
enumerator linux_riscv64#
enumerator osx_64#
enumerator osx_arm64#
enumerator win_32#
enumerator win_64#
enumerator win_arm64#
enumerator zos_z#
enumerator count_#
enum class NoArchType#

Noarch packages are packages that are not architecture specific.

Noarch packages only have to be built once.

Values:

enumerator No#

Not a noarch type.

enumerator Generic#

Noarch generic packages allow users to distribute docs, datasets, and source code.

enumerator Python#

A noarch python package is a python package without any precompiled python files.

Normally, precompiled files (.pyc or __pycache__) are bundled with the package. However, these files are tied to a specific version of Python and must therefore be generated for every target platform and architecture. This complicates the build process. For noarch Python packages these files are generated when installing the package by invoking the compilation process through the python binary that is installed in the same environment.

enumerator count_#

Functions

template<typename Str, std::enable_if_t<std::is_convertible_v<Str, std::string_view>, bool> = true>
auto has_archive_extension(const Str &path) -> bool#

Detect if the package path has one of the known archive extension.

auto has_archive_extension(std::string_view path) -> bool#
auto has_archive_extension(const fs::u8path &path) -> bool#
template<typename Str, std::enable_if_t<std::is_convertible_v<Str, std::string_view>, bool> = true>
auto strip_archive_extension(const Str &path) -> std::string_view#

Remove the known archive extension from the package path if present.

auto strip_archive_extension(std::string_view path) -> std::string_view#
auto strip_archive_extension(fs::u8path path) -> fs::u8path#
auto operator==(const BasicHTTPAuthentication &a, const BasicHTTPAuthentication &b) -> bool#
auto operator!=(const BasicHTTPAuthentication &a, const BasicHTTPAuthentication &b) -> bool#
auto operator==(const BearerToken &a, const BearerToken &b) -> bool#
auto operator!=(const BearerToken &a, const BearerToken &b) -> bool#
auto operator==(const CondaToken &a, const CondaToken &b) -> bool#
auto operator!=(const CondaToken &a, const CondaToken &b) -> bool#
auto operator==(const BuildNumberPredicate &lhs, const BuildNumberPredicate &rhs) -> bool#
auto operator!=(const BuildNumberPredicate &lhs, const BuildNumberPredicate &rhs) -> bool#
auto operator==(const Channel &a, const Channel &b) -> bool#

Tuple-like equality of all observable members.

auto operator!=(const Channel &a, const Channel &b) -> bool#
auto operator==(const CondaURL &a, const CondaURL &b) -> bool#

Tuple-like equality of all observable members.

auto operator!=(const CondaURL &a, const CondaURL &b) -> bool#
auto operator/(const CondaURL &url, std::string_view subpath) -> CondaURL#

A functional equivalent to CondaURL::append_path.

auto operator/(CondaURL &&url, std::string_view subpath) -> CondaURL#
template<typename T>
auto make_unexpected_parse(T &&err) -> tl::unexpected<ParseError>#
auto operator==(const PackageInfo &lhs, const PackageInfo &rhs) -> bool#
auto operator!=(const PackageInfo &lhs, const PackageInfo &rhs) -> bool#
void to_json(nlohmann::json &j, const PackageInfo &pkg)#
void from_json(const nlohmann::json &j, PackageInfo &pkg)#
constexpr auto known_platforms_count() -> std::size_t#
constexpr auto known_platforms() -> std::array<KnownPlatform, known_platforms_count()>#
constexpr auto known_platform_names() -> std::array<std::string_view, known_platforms_count()>#
constexpr auto platform_name(KnownPlatform p) -> std::string_view#

Convert the enumeration to its conda string.

auto platform_parse(std::string_view str) -> std::optional<KnownPlatform>#

Return the enum matching the platform name.

auto platform_is_linux(KnownPlatform plat) -> bool#
auto platform_is_linux(DynamicPlatform plat) -> bool#
auto platform_is_osx(KnownPlatform plat) -> bool#
auto platform_is_osx(DynamicPlatform plat) -> bool#
auto platform_is_win(KnownPlatform plat) -> bool#
auto platform_is_win(DynamicPlatform plat) -> bool#
auto build_platform() -> KnownPlatform#

Detect the platform on which mamba was built.

auto build_platform_name() -> std::string_view#
void to_json(nlohmann::json &j, const KnownPlatform &p)#

Serialize to JSON string.

void from_json(const nlohmann::json &j, KnownPlatform &p)#

Deserialize from JSON string.

constexpr auto known_noarch_count() -> std::size_t#
constexpr auto known_noarch() -> std::array<NoArchType, known_noarch_count()>#
constexpr auto known_noarch_names() -> std::array<std::string_view, known_noarch_count()>#
constexpr auto noarch_name(NoArchType noarch) -> std::string_view#

Convert the enumeration to its conda string.

auto noarch_parse(std::string_view str) -> std::optional<NoArchType>#

Return the enum matching the noarch name.

void to_json(nlohmann::json &j, const NoArchType &noarch)#

Serialize to JSON string.

void from_json(const nlohmann::json &j, NoArchType &noarch)#

Deserialize from JSON string.

void to_json(nlohmann::json &j, const RepoDataPackage &p)#

Serialize to JSON.

Optional members are omitted from json.

void from_json(const nlohmann::json &j, RepoDataPackage &p)#

Deserialize from JSON.

Missing json entries fill optionals with a null values and collections as empty. Special handling of the following fields is performed:

  • "noarch" can be a string or a boolean (old behaviour), in which case false parse to std::nullopt and true to NoArchType::Generic.

  • "track_features" can be a string or list of string. In the former case, it is considered as a single element list.

void to_json(nlohmann::json &j, const ChannelInfo &info)#

Serialize to JSON.

void from_json(const nlohmann::json &j, ChannelInfo &info)#

Deserialize from JSON.

void to_json(nlohmann::json &j, const RepoData &data)#

Serialize to JSON.

Optional members are omitted from json.

void from_json(const nlohmann::json &j, RepoData &data)#

Deserialize from JSON.

Missing json entries fill optionals with a null values and collections as empty.

auto operator==(const VersionPredicate &lhs, const VersionPredicate &rhs) -> bool#
auto operator!=(const VersionPredicate &lhs, const VersionPredicate &rhs) -> bool#

Variables

static constexpr auto ARCHIVE_EXTENSIONS = std::array{std::string_view(".tar.bz2"), std::string_view(".conda"), std::string_view(".whl")}#
struct BasicHTTPAuthentication#

User and password authetification set in the URL.

Public Members

std::string user#
std::string password#
struct BearerToken#

HTTP Bearer token set in the request headers.

Public Members

std::string token#
class BuildNumberPredicate#

A stateful unary boolean function on the integer space.

Public Types

using BuildNumber = std::size_t#

Public Functions

BuildNumberPredicate() = default#

Construct an free interval.

auto contains(const BuildNumber &point) const -> bool#

True if the predicate contains the given build_number.

auto str() const -> std::string#

Public Static Functions

static auto make_free() -> BuildNumberPredicate#
static auto make_equal_to(BuildNumber ver) -> BuildNumberPredicate#
static auto make_not_equal_to(BuildNumber ver) -> BuildNumberPredicate#
static auto make_greater(BuildNumber ver) -> BuildNumberPredicate#
static auto make_greater_equal(BuildNumber ver) -> BuildNumberPredicate#
static auto make_less(BuildNumber ver) -> BuildNumberPredicate#
static auto make_less_equal(BuildNumber ver) -> BuildNumberPredicate#

Friends

friend class ::fmt::formatter< BuildNumberPredicate >
class BuildNumberSpec#

Match a build number with a predicate.

Conda does not implement expression for build numbers but they could be added similarily to VersionSpec.

Public Types

using BuildNumber = typename BuildNumberPredicate::BuildNumber#

Public Functions

BuildNumberSpec()#

Construct BuildNumberSpec that match all versions.

explicit BuildNumberSpec(BuildNumberPredicate predicate) noexcept#
auto is_explicitly_free() const -> bool#

Returns wether the BuildNumberSpec is unconstrained.

auto str() const -> std::string#

A string representation of the build number spec.

May not always be the same as the parsed string (due to reconstruction) but reparsing this string will give the same build number spec.

auto contains(BuildNumber point) const -> bool#

True if the set described by the BuildNumberSpec contains the given version.

Public Static Functions

static auto parse(std::string_view str) -> expected_parse_t<BuildNumberSpec>#

Public Static Attributes

static constexpr std::string_view prefered_free_str = "=*"#
static constexpr std::array<std::string_view, 4> all_free_strs = {"", "*", "=*", "==*"}#
static constexpr std::string_view equal_str = "="#
static constexpr std::string_view not_equal_str = "!="#
static constexpr std::string_view greater_str = ">"#
static constexpr std::string_view greater_equal_str = ">="#
static constexpr std::string_view less_str = "<"#
static constexpr std::string_view less_equal_str = "<="#

Friends

friend class ::fmt::formatter< BuildNumberSpec >
class Channel#

Public Types

enum class Match#

Values:

enumerator No#
enumerator InOtherPlatform#
enumerator Full#
using platform_list = ChannelResolveParams::platform_list#
using channel_list = ChannelResolveParams::channel_list#

Public Functions

Channel(CondaURL url, std::string display_name, platform_list platforms = {})#
Channel(std::vector<CondaURL> mirror_urls, std::string display_name, platform_list platforms = {})#
auto is_package() const -> bool#
auto mirror_urls() const -> const std::vector<CondaURL>&#
auto platform_mirror_urls() const -> std::vector<CondaURL>#
auto platform_mirror_urls(const std::string_view platform) const -> std::vector<CondaURL>#
auto url() const -> const CondaURL&#
auto clear_url() -> const CondaURL#
void set_url(CondaURL url)#
auto platform_urls() const -> std::vector<CondaURL>#
auto platform_url(std::string_view platform) const -> CondaURL#
auto platforms() const -> const platform_list&#
auto clear_platforms() -> platform_list#
void set_platforms(platform_list platforms)#
auto id() const -> const std::string&#
auto display_name() const -> const std::string&#
auto clear_display_name() -> std::string#
void set_display_name(std::string display_name)#
auto url_equivalent_with(const Channel &other) const -> bool#
auto is_equivalent_to(const Channel &other) const -> bool#
auto contains_equivalent(const Channel &other) const -> bool#
auto contains_package(const CondaURL &pkg) const -> Match#

Public Static Functions

static auto resolve(UnresolvedChannel uc, const ChannelResolveParams &params) -> expected_parse_t<channel_list>#
static auto resolve(UnresolvedChannel uc, ChannelResolveParamsView params) -> expected_parse_t<channel_list>#
struct ChannelInfo#

Information about subdirectory of channel in the Conda RepoData.

Public Members

KnownPlatform subdir = {}#

The channel’s subdirectory.

struct ChannelResolveParams#

Public Types

template<typename Key, typename Value>
using name_map = util::weakening_map<std::unordered_map<Key, Value>, NameWeakener>#
using platform_list = util::flat_set<std::string>#
using channel_list = std::vector<Channel>#
using channel_map = name_map<std::string, Channel>#
using multichannel_map = name_map<std::string, channel_list>#

Public Members

platform_list platforms = {}#
CondaURL channel_alias = {}#
channel_map custom_channels = {}#
multichannel_map custom_multichannels = {}#
AuthenticationDataBase authentication_db = {}#
std::string home_dir = {}#
std::string current_working_dir = {}#
struct NameWeakener#

The weakener for ResolveParams::custom_channels.

Public Functions

auto make_first_key(std::string_view key) const -> std::string_view#

Return the key unchanged.

auto weaken_key(std::string_view key) const -> std::optional<std::string_view>#

Remove the last element of the ‘/’-separated name.

struct ChannelResolveParamsView#

Public Members

const ChannelResolveParams::platform_list &platforms = {}#
const CondaURL &channel_alias = {}#
const ChannelResolveParams::channel_map &custom_channels = {}#
const ChannelResolveParams::multichannel_map &custom_multichannels = {}#
const AuthenticationDataBase &authentication_db = {}#
std::string_view home_dir = {}#
std::string_view current_working_dir = {}#
class ChimeraStringSpec#

A matcher for either a glob or a regex expression.

Public Types

using Chimera = std::variant<GlobSpec, RegexSpec>#

Public Functions

ChimeraStringSpec()#
explicit ChimeraStringSpec(Chimera spec)#
auto contains(std::string_view str) const -> bool#
auto is_explicitly_free() const -> bool#

Return true if the spec will match true on any input.

auto is_exact() const -> bool#

Return true if the spec will match exactly one input.

auto is_glob() const -> bool#

Return true if the spec is a glob and not a regex.

auto str() const -> const std::string&#

Public Static Functions

static auto parse(std::string pattern) -> expected_parse_t<ChimeraStringSpec>#
struct CondaToken#

A Conda token set in the URL path.

Public Members

std::string token#
class CondaURL : private mamba::util::URL#

Public Types

using StripScheme = util::detail::StripScheme#
using Credentials = util::detail::Credentials#
using Encode = util::detail::Encode#
using Decode = util::detail::Decode#

Public Functions

CondaURL() = default#

Create a local URL.

explicit CondaURL(util::URL &&url)#
explicit CondaURL(const util::URL &url)#
auto generic() const -> const util::URL&#
void set_path(std::string_view path, Encode::yes_type = Encode::yes)#

Set the path from a not encoded value.

All ‘/’ are not encoded but interpreted as separators. On windows with a file scheme, the colon after the drive letter is not encoded. A leading ‘/’ is added if abscent. If the path contains only a token, a trailing ‘/’ is added afterwards.

void set_path(std::string path, Encode::no_type)#

Set the path from an already encoded value.

A leading ‘/’ is added if abscent. If the path contains only a token, a trailing ‘/’ is added afterwards.

void append_path(std::string_view path, Encode::yes_type = Encode::yes)#

Append a not encoded sub path to the current path.

Contrary to std::filesystem::path::append, this always append and never replace the current path, even if subpath starts with a ‘/’. All ‘/’ are not encoded but interpreted as separators. If the final path contains only a token, a trailing ‘/’ is added afterwards.

void append_path(std::string_view path, Encode::no_type)#

Append a already encoded sub path to the current path.

Contrary to std::filesystem::path::append, this always append and never replace the current path, even if subpath starts with a ‘/’. If the final path contains only a token, a trailing ‘/’ is added afterwards.

auto has_token() const -> bool#

Return wether a token is set.

auto token() const -> std::string_view#

Return the Conda token, as delimited with “/t/”, or empty if there isn’t any.

void set_token(std::string_view token)#

Set a token.

If the URL already contains one replace it at the same location, otherwise, add it at the begining of the path.

auto clear_token() -> bool#

Clear the token and return true if it exists, otherwise return false.

auto path_without_token(Decode::no_type) const -> std::string_view#

Return the encoded part of the path without any Conda token, always start with ‘/’.

auto path_without_token(Decode::yes_type = Decode::yes) const -> std::string#

Return the decoded part of the path without any Conda token, always start with ‘/’.

void set_path_without_token(std::string_view path, Encode::no_type)#

Set the path from an already encoded value, without changing the Conda token.

A leading ‘/’ is added if abscent.

void set_path_without_token(std::string_view path, Encode::yes_type = Encode::yes)#

Set the path from an not yet encoded value, without changing the Conda token.

A leading ‘/’ is added if abscent.

auto clear_path_without_token() -> bool#

Clear the path without changing the Conda token and return true if it exists.

auto platform() const -> std::optional<KnownPlatform>#

Return the platform if part of the URL path.

auto platform_name() const -> std::string_view#

Return the platform if part of the URL path, or empty.

If a platform is found, it is returned as a view onto the path without normalization (for instance the capitalization isn’t changed).

void set_platform(KnownPlatform platform)#

Set the platform if the URL already contains one, or throw an error.

void set_platform(std::string_view platform)#

Set the platform if the URL already contains one, or throw an error.

If the input platform is a valid platform, it is inserted as it is into the path (for instance the capitalization isn’t changed).

auto clear_platform() -> bool#

Clear the token and return true if it exists, otherwise return false.

auto package(Decode::yes_type = Decode::yes) const -> std::string#

Return the encoded package name, or empty otherwise.

Package name are at the end of the path and end with a archive extension.

See also

has_archive_extension

auto package(Decode::no_type) const -> std::string_view#

Return the decoded package name, or empty otherwise.

Package name are at the end of the path and end with a archive extension.

See also

has_archive_extension

void set_package(std::string_view pkg, Encode::yes_type = Encode::yes)#

Change the package file name with a not encoded value.

If a package file name is present, replace it, otherwise add it at the end of the path.

void set_package(std::string_view pkg, Encode::no_type)#

Change the package file name with already encoded value.

If a package file name is present, replace it, otherwise add it at the end of the path.

auto clear_package() -> bool#

Clear the package and return true if it exists, otherwise return false.

auto str(Credentials credentials = Credentials::Hide) const -> std::string#

Return the full, exact, encoded URL.

auto pretty_str(StripScheme strip_scheme = StripScheme::no, char rstrip_path = 0, Credentials credentials = Credentials::Hide) const -> std::string#

Return the full decoded url.

Due to decoding, the outcome may not be understood by parser and usable to reach an asset.

Parameters:
  • strip_scheme – If true, remove the scheme and “localhost” on file URI.

  • rstrip_path – If non-null, remove the given charaters at the end of the path.

  • credentials – If true, hide password and tokens in the decoded string.

  • credentials – Decide to keep, remove, or hide passwrd, users, and token.

Public Static Functions

static auto parse(std::string_view url) -> expected_parse_t<CondaURL>#

Public Static Attributes

static constexpr std::string_view token_prefix = "/t/"#
class GlobSpec#

A matcher for glob expression.

Currently only support “*” wildcard for matching zero or more characters.

Public Functions

GlobSpec() = default#
explicit GlobSpec(std::string pattern)#
auto contains(std::string_view str) const -> bool#
auto is_free() const -> bool#

Return true if the spec will match true on any input.

auto is_exact() const -> bool#

Return true if the spec will match exaclty one input.

auto str() const -> const std::string&#

Public Static Attributes

static constexpr std::string_view free_pattern = "*"#
static constexpr char glob_pattern = '*'#
class MatchSpec#

Subclassed by mamba::solver::ProblemsGraph::ConstraintNode, mamba::solver::ProblemsGraph::UnresolvedDependencyNode

Public Types

using NameSpec = GlobSpec#
using BuildStringSpec = ChimeraStringSpec#
using platform_set = typename UnresolvedChannel::platform_set#
using platform_set_const_ref = std::reference_wrapper<const platform_set>#
using string_set = typename util::flat_set<std::string>#
using string_set_const_ref = typename std::reference_wrapper<const string_set>#

Public Functions

auto channel() const -> const std::optional<UnresolvedChannel>&#
void set_channel(std::optional<UnresolvedChannel> chan)#
auto filename() const -> std::string_view#
void set_filename(std::string val)#
auto is_file() const -> bool#
auto platforms() const -> std::optional<platform_set_const_ref>#
void set_platforms(platform_set val)#
auto name_space() const -> const std::string&#
void set_name_space(std::string ns)#
auto name() const -> const NameSpec&#
void set_name(NameSpec name)#
auto version() const -> const VersionSpec&#
void set_version(VersionSpec ver)#
auto build_number() const -> const BuildNumberSpec&#
void set_build_number(BuildNumberSpec num)#
auto build_string() const -> const BuildStringSpec&#
void set_build_string(BuildStringSpec bs)#
auto md5() const -> std::string_view#
void set_md5(std::string val)#
auto sha256() const -> std::string_view#
void set_sha256(std::string val)#
auto license() const -> std::string_view#
void set_license(std::string val)#
auto license_family() const -> std::string_view#
void set_license_family(std::string val)#
auto features() const -> std::string_view#
void set_features(std::string val)#
auto track_features() const -> std::optional<string_set_const_ref>#
void set_track_features(string_set val)#
auto optional() const -> bool#
void set_optional(bool opt)#
auto conda_build_form() const -> std::string#
auto str() const -> std::string#
auto is_simple() const -> bool#

Return true if the MatchSpec can be written as <name> <version> <build_string>.

auto is_only_package_name() const -> bool#

Return true if the MatchSpec contains an exact package name and nothing else.

template<typename Pkg>
auto contains_except_channel(const Pkg &pkg) const -> bool#

Check if the MatchSpec matches the given package.

The check exclude anything related to the channel, du to the difficulties in comparing unresolved channels and the fact that this check can be also be done once at a repository level when the user knows how packages are organised.

This function is written as a generic template, to acomodate various uses: the fact that the attributes may not always be in the correct format in the package, and that their parsing may be cached.

auto contains_except_channel(const PackageInfo &pkg) const -> bool#

Convenience wrapper making necessary convertions.

Public Static Functions

static auto parse(std::string_view spec) -> expected_parse_t<MatchSpec>#
static auto parse_url(std::string_view spec) -> expected_parse_t<MatchSpec>#

Public Static Attributes

static constexpr char url_md5_sep = '#'#
static constexpr char prefered_list_open = '['#
static constexpr char prefered_list_close = ']'#
static constexpr char alt_list_open = '('#
static constexpr char alt_list_close = ')'#
static constexpr char prefered_quote = '"'#
static constexpr char alt_quote = '\''#
static constexpr char channel_namespace_spec_sep = ':'#
static constexpr char attribute_sep = ','#
static constexpr char attribute_assign = '='#
static constexpr auto package_version_sep = std::array{' ', '=', '<', '>', '~', '!'}#
static constexpr auto feature_sep = std::array{' ', ','}#
class PackageInfo#

Subclassed by mamba::solver::ProblemsGraph::PackageNode

Public Functions

PackageInfo() = default#
explicit PackageInfo(std::string name)#
PackageInfo(std::string name, std::string version, std::string build_string, std::size_t build_number)#
auto json_signable() const -> nlohmann::json#
auto str() const -> std::string#
auto long_str() const -> std::string#
auto field(std::string_view name) const -> std::string#

Dynamically get a field (e.g.

name, version) as a string.

Public Members

std::string name = {}#
std::string version = {}#
std::string build_string = {}#
std::size_t build_number = 0#
std::string channel = {}#

Could contain “conda-forge”, “conda-forge/linux-64”, or a url.

Todo:

need to use a proper type for channels

std::string package_url = {}#
DynamicPlatform platform = {}#
std::string filename = {}#
std::string license = {}#
std::string md5 = {}#
std::string sha256 = {}#
std::string signatures = {}#
std::vector<std::string> track_features = {}#
std::vector<std::string> dependencies = {}#
std::vector<std::string> constrains = {}#
std::vector<std::string> defaulted_keys = {}#
NoArchType noarch = NoArchType::No#
std::size_t size = 0#
std::size_t timestamp = 0#
PackageType package_type = PackageType::Unknown#

Public Static Functions

static auto from_url(std::string_view url) -> expected_parse_t<PackageInfo>#
struct ParseError : public std::invalid_argument#
class RegexSpec#

A matcher for regex expression.

Public Functions

RegexSpec()#
RegexSpec(std::regex pattern, std::string raw_pattern)#
auto contains(std::string_view str) const -> bool#
auto is_explicitly_free() const -> bool#

Return true if the spec will match true on any input.

auto is_exact() const -> bool#

Return true if the spec will match exaclty one input.

auto str() const -> const std::string&#

Public Static Functions

static auto parse(std::string pattern) -> expected_parse_t<RegexSpec>#

Public Static Attributes

static constexpr std::string_view free_pattern = ".*"#
static constexpr char pattern_start = '^'#
static constexpr char pattern_end = '$'#
struct RepoData#

The repository data structure.

This schema maps to the repository repodata.json.

Public Members

std::optional<std::size_t> version = {}#

The version of the repodata format.

std::optional<ChannelInfo> info = {}#

The channel information contained in the repodata.json file.

std::map<std::string, RepoDataPackage> packages = {}#

The tar.bz2 packages contained in the repodata.json file.

Maps a filename sucha as libmamba-0.13.0-h3a044de_0.tar.bz2 to its RepoDataPackage.

std::map<std::string, RepoDataPackage> conda_packages = {}#

The conda packages contained in the repodata.json file.

Maps a filename such as libmamba-1.3.0-hcea66bb_1.conda to its RepoDataPackage. This is put under a different key for backwards compatibility with previous conda versions.

std::vector<std::string> removed = {}#

Removed packages.

These files are still accessible, but they are not installable like regular packages.

struct RepoDataPackage#

A single record in the Conda repodata.json.

A single record refers to a single binary distribution of a package on a Conda channel.

Looking at the RepoDataPackage class in the Conda source code a record can also include the following fields but it is unclear what they do.

  • std::optional<std::string> preferred_env;

  • std::optional<std::string> date;

  • ? package_type Repodata also contains some of the following keys, although they are not parsed by Conda.

std::optional<std::string> app_type;

  • std::optional<std::string> app_entry;

See also

conda.models.records conda/conda

See also

rattler_conda_types::repo_data::PackageRecord mamba-org/rattler

Public Members

std::string name = {}#

The name of the package.

Version version = Version(0, {{{0}}})#

The version of the package.

std::string build_string = {}#

The build string of the package.

std::size_t build_number = {}#

The build number of the package.

std::optional<std::string> subdir = {}#

The subdirectory where the package can be found.

This is likely not used as it contains not so useful strings such as “linux”.

std::optional<std::string> md5 = {}#

Optionally a MD5 hash of the package archive.

std::optional<std::string> sha256 = {}#

Optionally a SHA256 hash of the package archive.

std::optional<std::string> legacy_bz2_md5 = {}#

A deprecated md5 hash.

std::optional<std::size_t> legacy_bz2_size = {}#

A deprecated package archive size.

std::optional<std::size_t> size = {}#

Optionally the size of the package archive in bytes.

std::optional<std::string> arch = {}#

Optionally the architecture the package supports.

std::optional<std::string> platform = {}#

Optionally the platform the package supports.

std::vector<std::string> depends = {}#

Specification of packages this package depends on.

std::vector<std::string> constrains = {}#

Additional constraints on packages.

constrains are different from depends in that packages specified in depends must be installed next to this package, whereas packages specified in constrains are not required to be installed, but if they are installed they must follow these constraints.

std::vector<std::string> track_features = {}#

Track features are nowadays only used to deprioritize packages.

To that effect, the number of track features is counted (number of commas) and the package is downweighted by the number of track_features.

std::optional<std::string> features = {}#

Features are a deprecated way to specify different feature sets for the conda solver.

This is not supported anymore and should not be used. Instead, mutex packages should be used to specify mutually exclusive features.

std::optional<NoArchType> noarch = {}#

If this package is independent of architecture this field specifies in what way.

std::optional<std::string> license = {}#

The specific license of the package.

std::optional<std::string> license_family = {}#

The license family.

std::optional<std::size_t> timestamp = {}#

The UNIX Epoch timestamp when this package was created.

Note that sometimes this is specified in seconds and sometimes in milliseconds.

class UnresolvedChannel#

Unresolved Channel specification.

This represent an unverified channel string passed by the user, or written through files. Due the the heavy reliance of channels on configuration options, this placeholder type can be used to represent channel inputs that have not been “resolved” to s specific location. This can even be true when a full URL or path is given, as some authentification information may come from login database.

Note that for a string to be considered a URL, it must have an explicit scheme. So “repo.anaconda.com” is considered a name, similarily to “conda-forge” and not a URL. This is because otherwise it is not possible to tell names and URL appart.

Public Types

enum class Type#

Values:

enumerator URL#

A URL to a full repo strucuture.

Example “https://repo.anaconda.com/conda-forge”.

enumerator PackageURL#

A URL to a single package.

Example “https://repo.anaconda.com/conda-forge/linux-64/pkg-0.0-bld.conda”.

enumerator Path#

An (possibly implicit) path to a full repo strucuture.

Example “/Users/name/conda-bld”, “./conda-bld”, “~/.conda-bld”.

enumerator PackagePath#

An (possibly implicit) path to a single-package.

Example “/tmp/pkg-0.0-bld.conda”, “./pkg-0.0-bld.conda”, “~/pkg-0.0-bld.tar.bz2”.

enumerator Name#

A relative name.

It needs to be resolved using a channel alias, or a custom channel. Example “conda-forge”, “locals”, “my-channel/my-label”.

enumerator Unknown#

An unknown channel source.

It is currently unclear why it is needed.

using platform_set = util::flat_set<DynamicPlatform>#

Public Functions

UnresolvedChannel() = default#
UnresolvedChannel(std::string location, platform_set filters, Type type)#
auto type() const -> Type#
auto location() const & -> const std::string&#
auto location() && -> std::string#
auto clear_location() -> std::string#
auto platform_filters() const & -> const platform_set&#
auto platform_filters() && -> platform_set#
auto clear_platform_filters() -> platform_set#
auto is_package() const -> bool#
auto str() const -> std::string#

Public Static Functions

static auto parse_platform_list(std::string_view plats) -> platform_set#
static auto parse(std::string_view str) -> expected_parse_t<UnresolvedChannel>#

Public Static Attributes

static constexpr std::string_view platform_separators = "|,;"#
static constexpr std::string_view unknown_channel = "<unknown>"#
static constexpr std::array<std::string_view, 4> invalid_channels_lower = {"<unknown>", "none:///<unknown>", "none", ":///<unknown>",}#
struct URLWeakener#

The weakener for AuthenticationDataBase.

Public Functions

auto make_first_key(std::string_view key) const -> std::string#

Add a trailing ‘/’ if abscent.

This lets “mamba.org/” be found by “mamba.org” key.

auto weaken_key(std::string_view key) const -> std::optional<std::string_view>#

Remove the last part of the URL path, or simply the trailing slash.

For instance, iterations mya follow “mamba.org/p/chan” > “mamba.org/p/” > “mamba.org/p” > “mamba.org/” > “mamba.org”.

class Version#

A version according to Conda specifications.

A verison is composed of

  • A epoch number, usually 0;

  • A regular version,

  • An optional local. These elements are used to lexicographicaly compare two versions.

See also

conda/conda

Public Functions

Version() noexcept = default#

Construct version 0.0.

Version(std::size_t epoch, CommonVersion version, CommonVersion local = {}) noexcept#
auto epoch() const noexcept -> std::size_t#
auto version() const noexcept -> const CommonVersion&#
auto local() const noexcept -> const CommonVersion&#
auto str() const -> std::string#

A string representation of the version.

May not always be the same as the parsed string (due to reconstruction) but reparsing this string will give the same version. v == Version::parse(v.str()).

auto str(std::size_t level) const -> std::string#

A string truncated of extended representation of the version.

Represent the string with the desired number of parts. If the actual number of parts is larger, then the string is truncated. If the actual number of parts is smalle, then the string is expanded with zeros.

auto operator==(const Version &other) const -> bool#
auto operator!=(const Version &other) const -> bool#
auto operator<(const Version &other) const -> bool#
auto operator<=(const Version &other) const -> bool#
auto operator>(const Version &other) const -> bool#
auto operator>=(const Version &other) const -> bool#
auto starts_with(const Version &prefix) const -> bool#

Return true if this version starts with the other prefix.

For instance 1.2.3 starts with 1.2 but not the opposite. Because Conda versions can contain an arbitrary number of segments, some of which with alpha releases, this function cannot be written as a comparison. One would need to comoare with a version with infinitely pre-release segments.

auto compatible_with(const Version &older, std::size_t level) const -> bool#

Return true if this version is a compatible upgrade to the given one.

For instance 1.3.1 is compatible with 1.2.1 at level 0 (first component 1 == 1), at level 1 (second component3 >= 2), but not at level two (because the second component is stricly larger3 > 2`). Compatible versions are always smaller than the current version.

Public Static Functions

static auto parse(std::string_view str) -> expected_parse_t<Version>#

Public Static Attributes

static constexpr char epoch_delim = '!'#
static constexpr char local_delim = '+'#
static constexpr char part_delim = '.'#
static constexpr char part_delim_alt = '-'#
static constexpr char part_delim_special = '_'#
class VersionPartAtom#

A succession of a number and a lowercase literal.

Comparison is done lexicographically, with the number first and the literal second. Certain literals have special meaning: “*” < “dev” < “_”< any other literal < “” < “post”

Public Functions

VersionPartAtom() noexcept = default#
VersionPartAtom(std::size_t numeral) noexcept#
VersionPartAtom(std::size_t numeral, std::string_view literal)#
template<typename Char>
VersionPartAtom(std::size_t numeral, std::basic_string<Char> literal)#
auto numeral() const noexcept -> std::size_t#
auto literal() const & noexcept -> const std::string&#
auto literal() && noexcept -> std::string#
auto str() const -> std::string#
auto operator==(const VersionPartAtom &other) const -> bool#
auto operator!=(const VersionPartAtom &other) const -> bool#
auto operator<(const VersionPartAtom &other) const -> bool#
auto operator<=(const VersionPartAtom &other) const -> bool#
auto operator>(const VersionPartAtom &other) const -> bool#
auto operator>=(const VersionPartAtom &other) const -> bool#
class VersionPredicate#

A stateful unary boolean function on the Version space.

Public Functions

VersionPredicate() = default#

Construct an free interval.

auto contains(const Version &point) const -> bool#

True if the predicate contains the given version.

auto str() const -> std::string#
auto str_conda_build() const -> std::string#

An alternative string representation of the version spec.

Attempts to be compatible with conda-build/libsolv.

Public Static Functions

static auto make_free() -> VersionPredicate#
static auto make_equal_to(Version ver) -> VersionPredicate#
static auto make_not_equal_to(Version ver) -> VersionPredicate#
static auto make_greater(Version ver) -> VersionPredicate#
static auto make_greater_equal(Version ver) -> VersionPredicate#
static auto make_less(Version ver) -> VersionPredicate#
static auto make_less_equal(Version ver) -> VersionPredicate#
static auto make_starts_with(Version ver) -> VersionPredicate#
static auto make_not_starts_with(Version ver) -> VersionPredicate#
static auto make_compatible_with(Version ver, std::size_t level) -> VersionPredicate#

Friends

friend class ::fmt::formatter< VersionPredicate >
class VersionSpec#

Represent a set of versions.

Internally, a VersionSpec is a binary expression tree of union (or) or intersections (and) of the sets represented by VersionPredicate.

The VersionSpec can itself be considered a complex predicate on the space of Version.

Due to the complex nature of the expression system (comutativity, associativity, etc.), there is no easy way to say if two VersionSpecs are equal.

Public Types

using tree_type = util::flat_bool_expr_tree<VersionPredicate>#

Public Functions

VersionSpec() = default#

Construct VersionSpec that match all versions.

explicit VersionSpec(tree_type &&tree) noexcept#
auto is_explicitly_free() const -> bool#

Returns wether the VersionSpec is unconstrained.

Due to the complex nature of VersionSpec expressions, it is not always easy to know whether a complex expression can be simpified to the unconstrained one. This functions only handles the trivial cases.

auto str() const -> std::string#

A string representation of the version spec.

May not always be the same as the parsed string (due to reconstruction) but reparsing this string will give the same version spec.

auto str_conda_build() const -> std::string#

An alternative string representation of the version spec.

Attempts to be compatible with conda-build/libsolv.

auto contains(const Version &point) const -> bool#

True if the set described by the VersionSpec contains the given version.

auto expression_size() const -> std::size_t#

Return the size of the boolean expression tree.

Public Static Functions

static auto parse(std::string_view str) -> expected_parse_t<VersionSpec>#
static auto from_predicate(VersionPredicate pred) -> VersionSpec#

Create a Version spec with a single predicate in the expression.

Public Static Attributes

static constexpr char and_token = ','#
static constexpr char or_token = '|'#
static constexpr char left_parenthesis_token = '('#
static constexpr char right_parenthesis_token = ')'#
static constexpr std::string_view prefered_free_str = "=*"#
static constexpr std::array<std::string_view, 4> all_free_strs = {"", "*", "=*", "==*"}#
static constexpr std::string_view starts_with_str = "="#
static constexpr std::string_view equal_str = "=="#
static constexpr std::string_view not_equal_str = "!="#
static constexpr std::string_view greater_str = ">"#
static constexpr std::string_view greater_equal_str = ">="#
static constexpr std::string_view less_str = "<"#
static constexpr std::string_view less_equal_str = "<="#
static constexpr std::string_view compatible_str = "~="#
static constexpr std::string_view glob_suffix_str = ".*"#
static constexpr char glob_suffix_token = '*'#

Friends

friend class ::fmt::formatter< VersionSpec >
namespace build_number_spec_literals#

Functions

auto operator""_bs(const char *str, std::size_t len) -> BuildNumberSpec#
namespace conda_url_literals#

Functions

auto operator""_cu(const char *str, std::size_t len) -> CondaURL#
namespace match_spec_literals#

Functions

auto operator""_ms(const char *str, std::size_t len) -> MatchSpec#
namespace version_literals#

Functions

auto operator""_v(const char *str, std::size_t len) -> Version#
namespace version_spec_literals#

Functions

auto operator""_vs(const char *str, std::size_t len) -> VersionSpec#