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 multiple 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 representation 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 arbitrary positive 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#
enumerator TarGz#
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>
bool has_archive_extension(const Str &path)#

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

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

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

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

Tuple-like equality of all observable members.

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

Tuple-like equality of all observable members.

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

A functional equivalent to CondaURL::append_path.

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

Convert the enumeration to its conda string.

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

Return the enum matching the platform name.

bool platform_is_linux(KnownPlatform plat)#
bool platform_is_linux(DynamicPlatform plat)#
bool platform_is_osx(KnownPlatform plat)#
bool platform_is_osx(DynamicPlatform plat)#
bool platform_is_win(KnownPlatform plat)#
bool platform_is_win(DynamicPlatform plat)#
KnownPlatform build_platform()#

Detect the platform on which mamba was built.

std::string_view build_platform_name()#
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.

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

Convert the enumeration to its conda string.

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

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.

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

Variables

static auto ARCHIVE_EXTENSIONS = std::array{std::string_view(".tar.bz2"), std::string_view(".conda"), std::string_view(".whl"), std::string_view(".tar.gz")}#
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.

bool contains(const BuildNumber &point) const#

True if the predicate contains the given build_number.

std::string str() const#

Public Static Functions

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

Friends

friend struct ::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 similarly to VersionSpec.

Public Types

using BuildNumber = typename BuildNumberPredicate::BuildNumber#

Public Functions

BuildNumberSpec()#

Construct BuildNumberSpec that match all versions.

explicit BuildNumberSpec(BuildNumberPredicate predicate) noexcept#
bool is_explicitly_free() const#

Returns whether the BuildNumberSpec is unconstrained.

std::string str() const#

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.

bool contains(BuildNumber point) const#

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

inline bool operator==(const BuildNumberSpec &other) const#
inline bool operator!=(const BuildNumberSpec &other) const#

Public Static Functions

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

Public Static Attributes

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

Friends

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

Public Types

enum class Match#

Values:

enumerator No#
enumerator InOtherPlatform#
enumerator Full#
using platform_list = util::flat_set<std::string>#
using channel_list = std::vector<Channel>#

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

Public Static Functions

static expected_parse_t<channel_list> resolve(UnresolvedChannel uc, const ChannelResolveParams &params)#
static expected_parse_t<channel_list> resolve(UnresolvedChannel uc, ChannelResolveParamsView params)#
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

std::string_view make_first_key(std::string_view key) const#

Return the key unchanged.

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

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)#
bool contains(std::string_view str) const#
bool is_explicitly_free() const#

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

bool is_exact() const#

Return true if the spec will match exactly one input.

bool is_glob() const#

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

const std::string &str() const#
inline bool operator==(const ChimeraStringSpec &other) const#
inline bool operator!=(const ChimeraStringSpec &other) const#

Public Static Functions

static expected_parse_t<ChimeraStringSpec> parse(std::string pattern)#
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)#
const util::URL &generic() const#
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.

bool has_token() const#

Return whether a token is set.

std::string_view token() const#

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 beginning of the path.

bool clear_token()#

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

std::string_view path_without_token(Decode::no_type) const#

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

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

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.

bool clear_path_without_token()#

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

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

Return the platform if part of the URL path.

std::string_view platform_name() const#

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).

bool clear_platform()#

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

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

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

std::string_view package(Decode::no_type) const#

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.

bool clear_package()#

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

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

Return the full, exact, encoded URL.

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

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 characters 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 expected_parse_t<CondaURL> parse(std::string_view url)#

Public Static Attributes

static 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)#
bool contains(std::string_view str) const#
bool is_free() const#

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

bool is_exact() const#

Return true if the spec will match exactly one input.

const std::string &str() const#
inline bool operator==(const GlobSpec &other) const#
inline bool operator!=(const GlobSpec &other) const#

Public Static Attributes

static std::string_view free_pattern = "*"#
static 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

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

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

bool is_only_package_name() const#

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

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

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 accommodate 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.

bool contains_except_channel(const PackageInfo &pkg) const#

Convenience wrapper making necessary conversions.

inline bool operator==(const MatchSpec &other) const#
inline bool operator!=(const MatchSpec &other) const#
std::size_t extra_members_hash() const#

Public Static Functions

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

Public Static Attributes

static char url_md5_sep = '#'#
static char preferred_list_open = '['#
static char preferred_list_close = ']'#
static char alt_list_open = '('#
static char alt_list_close = ')'#
static char preferred_quote = '"'#
static char alt_quote = '\''#
static char channel_namespace_spec_sep = ':'#
static char attribute_sep = ','#
static char attribute_assign = '='#
static auto package_version_sep = std::array{' ', '=', '<', '>', '~', '!'}#
static auto feature_sep = std::array{' ', ','}#

Friends

friend struct std::hash< MatchSpec::ExtraMembers >
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)#
PackageInfo(std::string name, std::string version, std::string build_string, std::string channel)#
nlohmann::json json_signable() const#
std::string str() const#
std::string long_str() const#
std::string field(std::string_view name) const#

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 expected_parse_t<PackageInfo> from_url(std::string_view url)#
struct ParseError : public std::invalid_argument#
class RegexSpec#

A matcher for regex expression.

Public Functions

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

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

bool is_exact() const#

Return true if the spec will match exactly one input.

const std::string &str() const#
inline bool operator==(const RegexSpec &other) const#
inline bool operator!=(const RegexSpec &other) const#

Public Static Functions

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

Public Static Attributes

static std::string_view free_pattern = ".*"#
static char pattern_start = '^'#
static 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 authentication 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, similarly to “conda-forge” and not a URL. This is because otherwise it is not possible to tell names and URL apart.

Public Types

enum class Type#

Values:

enumerator URL#

A URL to a full repo structure.

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 structure.

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)#
Type type() const#
const std::string &location() const &#
std::string location() &&#
std::string clear_location()#
const platform_set &platform_filters() const &#
platform_set platform_filters() &&#
platform_set clear_platform_filters()#
bool is_package() const#
std::string str() const#
inline bool operator==(const UnresolvedChannel &other) const#
inline bool operator!=(const UnresolvedChannel &other) const#

Public Static Functions

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

Public Static Attributes

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

The weakener for AuthenticationDataBase.

Public Functions

std::string make_first_key(std::string_view key) const#

Add a trailing ‘/’ if abscent.

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

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

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 version 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#
std::size_t epoch() const noexcept#
const CommonVersion &version() const noexcept#
const CommonVersion &local() const noexcept#
std::string str() const#

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()).

std::string str(std::size_t level) const#

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.

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

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.

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

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 strictly larger3 > 2`). Compatible versions are always smaller than the current version.

Public Static Functions

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

Public Static Attributes

static char epoch_delim = '!'#
static char local_delim = '+'#
static char part_delim = '.'#
static char part_delim_alt = '-'#
static 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)#
std::size_t numeral() const noexcept#
const std::string &literal() const & noexcept#
std::string literal() && noexcept#
std::string str() const#
bool operator==(const VersionPartAtom &other) const#
bool operator!=(const VersionPartAtom &other) const#
bool operator<(const VersionPartAtom &other) const#
bool operator<=(const VersionPartAtom &other) const#
bool operator>(const VersionPartAtom &other) const#
bool operator>=(const VersionPartAtom &other) const#
class VersionPredicate#

A stateful unary boolean function on the Version space.

Public Functions

VersionPredicate() = default#

Construct an free interval.

bool contains(const Version &point) const#

True if the predicate contains the given version.

std::string str() const#
std::string str_conda_build() const#

An alternative string representation of the version spec.

Attempts to be compatible with conda-build/libsolv.

Public Static Functions

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

Friends

friend struct ::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#
bool is_explicitly_free() const#

Returns whether 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 simplified to the unconstrained one. This functions only handles the trivial cases.

std::string str() const#

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.

std::string str_conda_build() const#

An alternative string representation of the version spec.

Attempts to be compatible with conda-build/libsolv.

bool contains(const Version &point) const#

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

std::size_t expression_size() const#

Return the size of the boolean expression tree.

inline bool operator==(const VersionSpec &other) const#
inline bool operator!=(const VersionSpec &other) const#

Public Static Functions

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

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

Public Static Attributes

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

Friends

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

Functions

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

Functions

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

Functions

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

Functions

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

Functions

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