mirror of https://github.com/mamba-org/mamba.git
Subdir renaming (#3214)
* Rename PackageInfo::depends > dependencies * Change BuildNumberSpec nuild number type * Rename MatchSpec::subdirs > platforms * Rename Platform > KnownPlatform * Add DynamicPlatform alias * Rename PackageInfo::subdir > platform * Fix build platform * Fix PackageInfo::platform on OSX
This commit is contained in:
parent
9965527410
commit
fd42d8dd8e
|
@ -25,7 +25,7 @@ namespace mamba::specs
|
|||
{
|
||||
public:
|
||||
|
||||
using BuildNumber = int;
|
||||
using BuildNumber = std::size_t;
|
||||
|
||||
[[nodiscard]] static auto make_free() -> BuildNumberPredicate;
|
||||
[[nodiscard]] static auto make_equal_to(BuildNumber ver) -> BuildNumberPredicate;
|
||||
|
|
|
@ -146,7 +146,7 @@ namespace mamba::specs
|
|||
auto clear_path_without_token() -> bool;
|
||||
|
||||
/** Return the platform if part of the URL path. */
|
||||
[[nodiscard]] auto platform() const -> std::optional<Platform>;
|
||||
[[nodiscard]] auto platform() const -> std::optional<KnownPlatform>;
|
||||
|
||||
/**
|
||||
* Return the platform if part of the URL path, or empty.
|
||||
|
@ -157,7 +157,7 @@ namespace mamba::specs
|
|||
[[nodiscard]] auto platform_name() const -> std::string_view;
|
||||
|
||||
/** Set the platform if the URL already contains one, or throw an error. */
|
||||
void set_platform(Platform platform);
|
||||
void set_platform(KnownPlatform platform);
|
||||
|
||||
/**
|
||||
* Set the platform if the URL already contains one, or throw an error.
|
||||
|
|
|
@ -27,8 +27,8 @@ namespace mamba::specs
|
|||
|
||||
using NameSpec = GlobSpec;
|
||||
using BuildStringSpec = GlobSpec;
|
||||
using subdir_list = typename UnresolvedChannel::dynamic_platform_set;
|
||||
using subdir_list_const_ref = std::reference_wrapper<const subdir_list>;
|
||||
using platform_set = typename UnresolvedChannel::platform_set;
|
||||
using platform_set_const_ref = std::reference_wrapper<const platform_set>;
|
||||
|
||||
inline static constexpr char url_md5_sep = '#';
|
||||
inline static constexpr char prefered_list_open = '[';
|
||||
|
@ -55,8 +55,8 @@ namespace mamba::specs
|
|||
|
||||
[[nodiscard]] auto is_file() const -> bool;
|
||||
|
||||
[[nodiscard]] auto subdirs() const -> std::optional<subdir_list_const_ref>;
|
||||
void set_subdirs(subdir_list val);
|
||||
[[nodiscard]] auto platforms() const -> std::optional<platform_set_const_ref>;
|
||||
void set_platforms(platform_set val);
|
||||
|
||||
[[nodiscard]] auto name_space() const -> const std::string&;
|
||||
void set_name_space(std::string ns);
|
||||
|
@ -106,7 +106,7 @@ namespace mamba::specs
|
|||
// The filename is stored as part of the channel when it is a full Package URL
|
||||
std::string filename = {};
|
||||
// The filename is stored as part of the channel when it is available
|
||||
subdir_list subdirs = {};
|
||||
platform_set subdirs = {};
|
||||
std::string md5 = {};
|
||||
std::string sha256 = {};
|
||||
std::string license = {};
|
||||
|
@ -133,8 +133,8 @@ namespace mamba::specs
|
|||
[[nodiscard]] auto extra_filename() const -> std::string_view;
|
||||
void set_extra_filename(std::string val);
|
||||
|
||||
[[nodiscard]] auto extra_subdirs() const -> std::optional<subdir_list_const_ref>;
|
||||
void set_extra_subdirs(subdir_list val);
|
||||
[[nodiscard]] auto extra_subdirs() const -> std::optional<platform_set_const_ref>;
|
||||
void set_extra_subdirs(platform_set val);
|
||||
};
|
||||
|
||||
namespace match_spec_literals
|
||||
|
|
|
@ -40,14 +40,14 @@ namespace mamba::specs
|
|||
*/
|
||||
std::string channel = {};
|
||||
std::string package_url = {};
|
||||
std::string subdir = {};
|
||||
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> depends = {};
|
||||
std::vector<std::string> dependencies = {};
|
||||
std::vector<std::string> constrains = {};
|
||||
std::vector<std::string> defaulted_keys = {};
|
||||
NoArchType noarch = NoArchType::No;
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace mamba::specs
|
|||
* When one platform name is the substring of another, the longest appears first so that
|
||||
* it makes it easier to use in a parser.
|
||||
*/
|
||||
enum class Platform
|
||||
enum class KnownPlatform
|
||||
{
|
||||
noarch = 0,
|
||||
linux_32,
|
||||
|
@ -46,40 +46,42 @@ namespace mamba::specs
|
|||
count_,
|
||||
};
|
||||
|
||||
using DynamicPlatform = std::string;
|
||||
|
||||
constexpr auto known_platforms_count() -> std::size_t
|
||||
{
|
||||
return static_cast<std::size_t>(Platform::count_);
|
||||
return static_cast<std::size_t>(KnownPlatform::count_);
|
||||
}
|
||||
|
||||
constexpr auto known_platforms() -> std::array<Platform, known_platforms_count()>;
|
||||
constexpr auto known_platforms() -> std::array<KnownPlatform, known_platforms_count()>;
|
||||
|
||||
constexpr auto known_platform_names() -> std::array<std::string_view, known_platforms_count()>;
|
||||
|
||||
/**
|
||||
* Convert the enumeration to its conda string.
|
||||
*/
|
||||
constexpr auto platform_name(Platform p) -> std::string_view;
|
||||
constexpr auto platform_name(KnownPlatform p) -> std::string_view;
|
||||
|
||||
/**
|
||||
* Return the enum matching the platform name.
|
||||
*/
|
||||
auto platform_parse(std::string_view str) -> std::optional<Platform>;
|
||||
auto platform_parse(std::string_view str) -> std::optional<KnownPlatform>;
|
||||
|
||||
/**
|
||||
* Detect the platform on which mamba was built.
|
||||
*/
|
||||
auto build_platform() -> Platform;
|
||||
auto build_platform() -> KnownPlatform;
|
||||
auto build_platform_name() -> std::string_view;
|
||||
|
||||
/**
|
||||
* Serialize to JSON string.
|
||||
*/
|
||||
void to_json(nlohmann::json& j, const Platform& p);
|
||||
void to_json(nlohmann::json& j, const KnownPlatform& p);
|
||||
|
||||
/**
|
||||
* Deserialize from JSON string.
|
||||
*/
|
||||
void from_json(const nlohmann::json& j, Platform& p);
|
||||
void from_json(const nlohmann::json& j, KnownPlatform& p);
|
||||
|
||||
/**
|
||||
* Noarch packages are packages that are not architecture specific.
|
||||
|
@ -148,55 +150,55 @@ namespace mamba::specs
|
|||
* Implementation *
|
||||
********************/
|
||||
|
||||
constexpr auto platform_name(Platform p) -> std::string_view
|
||||
constexpr auto platform_name(KnownPlatform p) -> std::string_view
|
||||
{
|
||||
switch (p)
|
||||
{
|
||||
case Platform::noarch:
|
||||
case KnownPlatform::noarch:
|
||||
return "noarch";
|
||||
case Platform::linux_32:
|
||||
case KnownPlatform::linux_32:
|
||||
return "linux-32";
|
||||
case Platform::linux_64:
|
||||
case KnownPlatform::linux_64:
|
||||
return "linux-64";
|
||||
case Platform::linux_armv6l:
|
||||
case KnownPlatform::linux_armv6l:
|
||||
return "linux-armv6l";
|
||||
case Platform::linux_armv7l:
|
||||
case KnownPlatform::linux_armv7l:
|
||||
return "linux-armv7l";
|
||||
case Platform::linux_aarch64:
|
||||
case KnownPlatform::linux_aarch64:
|
||||
return "linux-aarch64";
|
||||
case Platform::linux_ppc64:
|
||||
case KnownPlatform::linux_ppc64:
|
||||
return "linux-ppc64";
|
||||
case Platform::linux_ppc64le:
|
||||
case KnownPlatform::linux_ppc64le:
|
||||
return "linux-ppc64le";
|
||||
case Platform::linux_s390x:
|
||||
case KnownPlatform::linux_s390x:
|
||||
return "linux-s390x";
|
||||
case Platform::linux_riscv32:
|
||||
case KnownPlatform::linux_riscv32:
|
||||
return "linux-riscv32";
|
||||
case Platform::linux_riscv64:
|
||||
case KnownPlatform::linux_riscv64:
|
||||
return "linux-riscv64";
|
||||
case Platform::osx_64:
|
||||
case KnownPlatform::osx_64:
|
||||
return "osx-64";
|
||||
case Platform::osx_arm64:
|
||||
case KnownPlatform::osx_arm64:
|
||||
return "osx-arm64";
|
||||
case Platform::win_32:
|
||||
case KnownPlatform::win_32:
|
||||
return "win-32";
|
||||
case Platform::win_64:
|
||||
case KnownPlatform::win_64:
|
||||
return "win-64";
|
||||
case Platform::win_arm64:
|
||||
case KnownPlatform::win_arm64:
|
||||
return "win-arm64";
|
||||
case Platform::zos_z:
|
||||
case KnownPlatform::zos_z:
|
||||
return "zos-z";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
constexpr auto known_platforms() -> std::array<Platform, known_platforms_count()>
|
||||
constexpr auto known_platforms() -> std::array<KnownPlatform, known_platforms_count()>
|
||||
{
|
||||
auto out = std::array<Platform, known_platforms_count()>{};
|
||||
auto out = std::array<KnownPlatform, known_platforms_count()>{};
|
||||
for (std::size_t idx = 0; idx < out.size(); ++idx)
|
||||
{
|
||||
out[idx] = static_cast<Platform>(idx);
|
||||
out[idx] = static_cast<KnownPlatform>(idx);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ namespace mamba::specs
|
|||
struct ChannelInfo
|
||||
{
|
||||
/** The channel's subdirectory. */
|
||||
Platform subdir = {};
|
||||
KnownPlatform subdir = {};
|
||||
};
|
||||
|
||||
/** Serialize to JSON. */
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <fmt/format.h>
|
||||
|
||||
#include "mamba/specs/error.hpp"
|
||||
#include "mamba/specs/platform.hpp"
|
||||
#include "mamba/util/flat_set.hpp"
|
||||
|
||||
namespace mamba::specs
|
||||
|
@ -87,14 +88,14 @@ namespace mamba::specs
|
|||
":///<unknown>",
|
||||
};
|
||||
|
||||
using dynamic_platform_set = util::flat_set<std::string>;
|
||||
using platform_set = util::flat_set<DynamicPlatform>;
|
||||
|
||||
[[nodiscard]] static auto parse_platform_list(std::string_view plats) -> dynamic_platform_set;
|
||||
[[nodiscard]] static auto parse_platform_list(std::string_view plats) -> platform_set;
|
||||
|
||||
[[nodiscard]] static auto parse(std::string_view str) -> expected_parse_t<UnresolvedChannel>;
|
||||
|
||||
UnresolvedChannel() = default;
|
||||
UnresolvedChannel(std::string location, dynamic_platform_set filters, Type type);
|
||||
UnresolvedChannel(std::string location, platform_set filters, Type type);
|
||||
|
||||
[[nodiscard]] auto type() const -> Type;
|
||||
|
||||
|
@ -102,16 +103,16 @@ namespace mamba::specs
|
|||
[[nodiscard]] auto location() && -> std::string;
|
||||
auto clear_location() -> std::string;
|
||||
|
||||
[[nodiscard]] auto platform_filters() const& -> const dynamic_platform_set&;
|
||||
[[nodiscard]] auto platform_filters() && -> dynamic_platform_set;
|
||||
auto clear_platform_filters() -> dynamic_platform_set;
|
||||
[[nodiscard]] auto platform_filters() const& -> const platform_set&;
|
||||
[[nodiscard]] auto platform_filters() && -> platform_set;
|
||||
auto clear_platform_filters() -> platform_set;
|
||||
|
||||
[[nodiscard]] auto str() const -> std::string;
|
||||
|
||||
private:
|
||||
|
||||
std::string m_location = std::string(unknown_channel);
|
||||
dynamic_platform_set m_platform_filters = {};
|
||||
platform_set m_platform_filters = {};
|
||||
Type m_type = Type::Unknown;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace mamba
|
|||
obj["channel"] = channels.front().display_name();
|
||||
obj["dist_name"] = pkg_info.str();
|
||||
obj["name"] = pkg_info.name;
|
||||
obj["platform"] = pkg_info.subdir;
|
||||
obj["platform"] = pkg_info.platform;
|
||||
obj["version"] = pkg_info.version;
|
||||
jout.push_back(obj);
|
||||
}
|
||||
|
|
|
@ -68,14 +68,14 @@ namespace mamba
|
|||
package.info.filename = maybe_parsed_info->filename;
|
||||
package.info.channel = maybe_parsed_info->channel;
|
||||
package.info.build_string = maybe_parsed_info->build_string;
|
||||
package.info.subdir = maybe_parsed_info->subdir;
|
||||
package.info.platform = maybe_parsed_info->platform;
|
||||
}
|
||||
|
||||
for (const auto& dependency : package_node["dependencies"])
|
||||
{
|
||||
const auto dependency_name = dependency.first.as<std::string>();
|
||||
const auto dependency_constraint = dependency.second.as<std::string>();
|
||||
package.info.depends.push_back(
|
||||
package.info.dependencies.push_back(
|
||||
fmt::format("{} {}", dependency_name, dependency_constraint)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -744,7 +744,7 @@ namespace mamba
|
|||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
if (binary_changed && m_pkg_info.subdir == "osx-arm64")
|
||||
if (binary_changed && m_pkg_info.platform == "osx-arm64")
|
||||
{
|
||||
codesign(dst, m_context->context().output_params.verbosity > 1);
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ namespace mamba
|
|||
{
|
||||
if (m_package_info.package_type == specs::PackageType::Conda)
|
||||
{
|
||||
return util::concat(m_package_info.subdir, '/', m_package_info.filename);
|
||||
return util::concat(m_package_info.platform, '/', m_package_info.filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace mamba
|
|||
// version are matched properly and that only names must be checked.
|
||||
for (const auto& [to_id, record] : dep_graph.nodes())
|
||||
{
|
||||
for (const auto& dep : record->depends)
|
||||
for (const auto& dep : record->dependencies)
|
||||
{
|
||||
// Creating a matchspec to parse the name (there may be a channel)
|
||||
auto ms = specs::MatchSpec::parse(dep)
|
||||
|
@ -174,7 +174,7 @@ namespace mamba
|
|||
// correct URL. This is must never happen!
|
||||
assert(channels.size() == 1);
|
||||
using Credentials = specs::CondaURL::Credentials;
|
||||
prec.channel = channels.front().platform_url(prec.subdir).str(Credentials::Remove);
|
||||
prec.channel = channels.front().platform_url(prec.platform).str(Credentials::Remove);
|
||||
m_package_records.insert({ prec.name, std::move(prec) });
|
||||
}
|
||||
} // namespace mamba
|
||||
|
|
|
@ -143,7 +143,7 @@ namespace mamba
|
|||
{
|
||||
return;
|
||||
}
|
||||
for (const auto& dep : m_graph.node(id).depends)
|
||||
for (const auto& dep : m_graph.node(id).dependencies)
|
||||
{
|
||||
// This is an approximation.
|
||||
// Resolving all depenndencies, even of a single Matchspec isnot as simple
|
||||
|
@ -303,7 +303,7 @@ namespace mamba
|
|||
fmt::print(out, fmtstring, "Build", pkg.build_string);
|
||||
fmt::print(out, " {:<15} {} kB\n", "Size", pkg.size / 1000);
|
||||
fmt::print(out, fmtstring, "License", pkg.license);
|
||||
fmt::print(out, fmtstring, "Subdir", pkg.subdir);
|
||||
fmt::print(out, fmtstring, "Subdir", pkg.platform);
|
||||
fmt::print(out, fmtstring, "File Name", pkg.filename);
|
||||
|
||||
using CondaURL = typename specs::CondaURL;
|
||||
|
@ -336,10 +336,10 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
if (!pkg.depends.empty())
|
||||
if (!pkg.dependencies.empty())
|
||||
{
|
||||
fmt::print(out, "\n Dependencies:\n");
|
||||
for (auto& d : pkg.depends)
|
||||
for (auto& d : pkg.dependencies)
|
||||
{
|
||||
fmt::print(out, " - {}\n", d);
|
||||
}
|
||||
|
@ -674,7 +674,7 @@ namespace mamba
|
|||
else if (cmd == "Depends")
|
||||
{
|
||||
std::string depends_qualifier;
|
||||
for (const auto& dep : pkg.depends)
|
||||
for (const auto& dep : pkg.dependencies)
|
||||
{
|
||||
if (util::starts_with(dep, args[i]))
|
||||
{
|
||||
|
|
|
@ -244,7 +244,7 @@ namespace mamba
|
|||
m_solution.actions,
|
||||
[&](const specs::PackageInfo& pkg)
|
||||
{
|
||||
for (const auto& dep : pkg.depends)
|
||||
for (const auto& dep : pkg.dependencies)
|
||||
{
|
||||
m_history_entry.update.push_back(dep);
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace mamba
|
|||
res.build_string = build_string.size() ? build_string : "0";
|
||||
res.build_number = 0;
|
||||
res.channel = "@";
|
||||
res.subdir = subdir;
|
||||
res.platform = subdir;
|
||||
res.md5 = "12345678901234567890123456789012";
|
||||
res.filename = name;
|
||||
return res;
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace mamba::solver::libsolv
|
|||
solv.set_build_number(pkg.build_number);
|
||||
solv.set_channel(pkg.channel);
|
||||
solv.set_url(pkg.package_url);
|
||||
solv.set_subdir(pkg.subdir);
|
||||
solv.set_subdir(pkg.platform);
|
||||
solv.set_file_name(pkg.filename);
|
||||
solv.set_license(pkg.license);
|
||||
solv.set_size(pkg.size);
|
||||
|
@ -59,7 +59,7 @@ namespace mamba::solver::libsolv
|
|||
solv.set_md5(pkg.md5);
|
||||
solv.set_sha256(pkg.sha256);
|
||||
|
||||
for (const auto& dep : pkg.depends)
|
||||
for (const auto& dep : pkg.dependencies)
|
||||
{
|
||||
// TODO pool's matchspec2id
|
||||
const solv::DependencyId dep_id = pool.add_conda_dependency(dep);
|
||||
|
@ -92,7 +92,7 @@ namespace mamba::solver::libsolv
|
|||
out.build_number = s.build_number();
|
||||
out.channel = s.channel();
|
||||
out.package_url = s.url();
|
||||
out.subdir = s.subdir();
|
||||
out.platform = s.subdir();
|
||||
out.filename = s.file_name();
|
||||
out.license = s.license();
|
||||
out.size = s.size();
|
||||
|
@ -104,8 +104,8 @@ namespace mamba::solver::libsolv
|
|||
{ return pool.dependency_to_string(id); };
|
||||
{
|
||||
const auto deps = s.dependencies();
|
||||
out.depends.reserve(deps.size());
|
||||
std::transform(deps.cbegin(), deps.cend(), std::back_inserter(out.depends), dep_to_str);
|
||||
out.dependencies.reserve(deps.size());
|
||||
std::transform(deps.cbegin(), deps.cend(), std::back_inserter(out.dependencies), dep_to_str);
|
||||
}
|
||||
{
|
||||
const auto cons = s.constraints();
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace mamba::specs
|
|||
* Not a static function, it is needed in "channel_spec.cpp".
|
||||
*/
|
||||
auto find_slash_and_platform(std::string_view path)
|
||||
-> std::tuple<std::size_t, std::size_t, std::optional<Platform>>
|
||||
-> std::tuple<std::size_t, std::size_t, std::optional<KnownPlatform>>
|
||||
{
|
||||
static constexpr auto npos = std::string_view::npos;
|
||||
|
||||
|
@ -272,7 +272,7 @@ namespace mamba::specs
|
|||
return path(Decode::no).size() != old_len;
|
||||
}
|
||||
|
||||
auto CondaURL::platform() const -> std::optional<Platform>
|
||||
auto CondaURL::platform() const -> std::optional<KnownPlatform>
|
||||
{
|
||||
const auto& l_path = path(Decode::no);
|
||||
assert(!l_path.empty() && (l_path.front() == '/'));
|
||||
|
@ -324,7 +324,7 @@ namespace mamba::specs
|
|||
return set_platform_no_check_input(platform);
|
||||
}
|
||||
|
||||
void CondaURL::set_platform(Platform platform)
|
||||
void CondaURL::set_platform(KnownPlatform platform)
|
||||
{
|
||||
return set_platform_no_check_input(specs::platform_name(platform));
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ namespace mamba::specs
|
|||
{
|
||||
if (auto chan = spec.channel(); !chan.has_value() || chan->platform_filters().empty())
|
||||
{
|
||||
spec.set_subdirs({ UnresolvedChannel::parse_platform_list(val) });
|
||||
spec.set_platforms({ UnresolvedChannel::parse_platform_list(val) });
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ namespace mamba::specs
|
|||
return !filename().empty();
|
||||
}
|
||||
|
||||
auto MatchSpec::extra_subdirs() const -> std::optional<subdir_list_const_ref>
|
||||
auto MatchSpec::extra_subdirs() const -> std::optional<platform_set_const_ref>
|
||||
{
|
||||
if (m_extra.has_value() && !m_extra->subdirs.empty())
|
||||
{
|
||||
|
@ -631,7 +631,7 @@ namespace mamba::specs
|
|||
return {};
|
||||
}
|
||||
|
||||
void MatchSpec::set_extra_subdirs(subdir_list val)
|
||||
void MatchSpec::set_extra_subdirs(platform_set val)
|
||||
{
|
||||
// Avoid allocating extra to set the default value
|
||||
if (m_extra.has_value() || !val.empty())
|
||||
|
@ -640,7 +640,7 @@ namespace mamba::specs
|
|||
}
|
||||
}
|
||||
|
||||
auto MatchSpec::subdirs() const -> std::optional<subdir_list_const_ref>
|
||||
auto MatchSpec::platforms() const -> std::optional<platform_set_const_ref>
|
||||
{
|
||||
if (m_channel.has_value() && !m_channel->platform_filters().empty())
|
||||
{
|
||||
|
@ -649,7 +649,7 @@ namespace mamba::specs
|
|||
return extra_subdirs();
|
||||
}
|
||||
|
||||
void MatchSpec::set_subdirs(subdir_list val)
|
||||
void MatchSpec::set_platforms(platform_set val)
|
||||
{
|
||||
if (m_channel.has_value())
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace mamba::specs
|
|||
out.package_type = parse_extension(spec);
|
||||
if (out.package_type == PackageType::Conda)
|
||||
{
|
||||
out.subdir = url.platform_name();
|
||||
out.platform = url.platform_name();
|
||||
url.clear_platform();
|
||||
out.channel = util::rstrip(url.str(), '/');
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ namespace mamba::specs
|
|||
// Mandatory keys
|
||||
j["name"] = name;
|
||||
j["version"] = version;
|
||||
j["subdir"] = subdir;
|
||||
j["subdir"] = platform;
|
||||
j["size"] = size;
|
||||
j["timestamp"] = timestamp;
|
||||
j["build"] = build_string;
|
||||
|
@ -185,7 +185,7 @@ namespace mamba::specs
|
|||
j["sha256"] = sha256;
|
||||
|
||||
// Defaulted keys to empty arrays
|
||||
if (depends.empty())
|
||||
if (dependencies.empty())
|
||||
{
|
||||
if (!contains(defaulted_keys, "depends"))
|
||||
{
|
||||
|
@ -194,7 +194,7 @@ namespace mamba::specs
|
|||
}
|
||||
else
|
||||
{
|
||||
j["depends"] = depends;
|
||||
j["depends"] = dependencies;
|
||||
}
|
||||
if (constrains.empty())
|
||||
{
|
||||
|
@ -290,7 +290,7 @@ namespace mamba::specs
|
|||
}
|
||||
if (field_name == "subdir")
|
||||
{
|
||||
return invoke_field_string(*this, &PackageInfo::subdir);
|
||||
return invoke_field_string(*this, &PackageInfo::platform);
|
||||
}
|
||||
if (field_name == "fn" || field_name == "filename")
|
||||
{
|
||||
|
@ -323,7 +323,7 @@ namespace mamba::specs
|
|||
p.build_number,
|
||||
p.channel,
|
||||
p.package_url,
|
||||
p.subdir,
|
||||
p.platform,
|
||||
p.filename,
|
||||
p.license,
|
||||
p.size,
|
||||
|
@ -331,7 +331,7 @@ namespace mamba::specs
|
|||
p.md5,
|
||||
p.sha256,
|
||||
p.track_features,
|
||||
p.depends,
|
||||
p.dependencies,
|
||||
p.constrains,
|
||||
p.signatures,
|
||||
p.defaulted_keys
|
||||
|
@ -355,7 +355,7 @@ namespace mamba::specs
|
|||
j["version"] = pkg.version;
|
||||
j["channel"] = pkg.channel;
|
||||
j["url"] = pkg.package_url; // The conda key name
|
||||
j["subdir"] = pkg.subdir;
|
||||
j["subdir"] = pkg.platform;
|
||||
j["fn"] = pkg.filename; // The conda key name
|
||||
j["size"] = pkg.size;
|
||||
j["timestamp"] = pkg.timestamp;
|
||||
|
@ -376,13 +376,13 @@ namespace mamba::specs
|
|||
{
|
||||
j["sha256"] = pkg.sha256;
|
||||
}
|
||||
if (pkg.depends.empty())
|
||||
if (pkg.dependencies.empty())
|
||||
{
|
||||
j["depends"] = nlohmann::json::array();
|
||||
}
|
||||
else
|
||||
{
|
||||
j["depends"] = pkg.depends;
|
||||
j["depends"] = pkg.dependencies;
|
||||
}
|
||||
|
||||
if (pkg.constrains.empty())
|
||||
|
@ -401,7 +401,7 @@ namespace mamba::specs
|
|||
pkg.version = j.value("version", "");
|
||||
pkg.channel = j.value("channel", "");
|
||||
pkg.package_url = j.value("url", "");
|
||||
pkg.subdir = j.value("subdir", "");
|
||||
pkg.platform = j.value("subdir", "");
|
||||
pkg.filename = j.value("fn", "");
|
||||
pkg.size = j.value("size", std::size_t(0));
|
||||
pkg.timestamp = j.value("timestamp", std::size_t(0));
|
||||
|
@ -440,7 +440,7 @@ namespace mamba::specs
|
|||
pkg.noarch = *it;
|
||||
}
|
||||
|
||||
pkg.depends = j.value("depends", std::vector<std::string>());
|
||||
pkg.dependencies = j.value("depends", std::vector<std::string>());
|
||||
pkg.constrains = j.value("constrains", std::vector<std::string>());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace mamba::specs
|
||||
{
|
||||
auto platform_parse(std::string_view str) -> std::optional<Platform>
|
||||
auto platform_parse(std::string_view str) -> std::optional<KnownPlatform>
|
||||
{
|
||||
const std::string str_clean = util::to_lower(util::strip(str));
|
||||
for (const auto p : known_platforms())
|
||||
|
@ -30,62 +30,62 @@ namespace mamba::specs
|
|||
/**
|
||||
* Detect the platform on which mamba was built.
|
||||
*/
|
||||
auto build_platform() -> Platform
|
||||
auto build_platform() -> KnownPlatform
|
||||
{
|
||||
#if defined(__linux__)
|
||||
#if __x86_64__
|
||||
return Platform::linux_64;
|
||||
return KnownPlatform::linux_64;
|
||||
#elif defined(i386)
|
||||
return Platform::linux_32;
|
||||
#elif defined(__arm__) || defined(__thumb__)
|
||||
#ifdef ___ARM_ARCH_6__
|
||||
return Platform::linux_armv6l;
|
||||
return KnownPlatform::linux_armv6l;
|
||||
#elif __ARM_ARCH_7__
|
||||
return Platform::linux_armv7l;
|
||||
return KnownPlatform::linux_armv7l;
|
||||
#else
|
||||
#error "Unknown Linux arm platform"
|
||||
#endif
|
||||
#elif _M_ARM == 6
|
||||
return Platform::linux_armv6l;
|
||||
return KnownPlatform::linux_armv6l;
|
||||
#elif _M_ARM == 7
|
||||
return Platform::linux_armv7l;
|
||||
return KnownPlatform::linux_armv7l;
|
||||
#elif defined(__aarch64__)
|
||||
return Platform::linux_aarch64;
|
||||
return KnownPlatform::linux_aarch64;
|
||||
#elif defined(__ppc64__) || defined(__powerpc64__)
|
||||
#if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
return Platform::linux_ppc64;
|
||||
return KnownPlatform::linux_ppc64;
|
||||
#else
|
||||
return Platform::linux_ppc64le;
|
||||
return KnownPlatform::linux_ppc64le;
|
||||
#endif
|
||||
#elif defined(__s390x__)
|
||||
return Platform::linux_s390x;
|
||||
return KnownPlatform::linux_s390x;
|
||||
#elif defined(__riscv) && defined(__riscv_xlen) && (__riscv_xlen == 32)
|
||||
return Platform::linux_riscv32;
|
||||
return KnownPlatform::linux_riscv32;
|
||||
#elif defined(__riscv) && defined(__riscv_xlen) && (__riscv_xlen == 64)
|
||||
return Platform::linux_riscv64;
|
||||
return KnownPlatform::linux_riscv64;
|
||||
#else
|
||||
#error "Unknown Linux platform"
|
||||
#endif
|
||||
|
||||
#elif defined(__APPLE__) || defined(__MACH__)
|
||||
#if __x86_64__
|
||||
return Platform::osx_64;
|
||||
return KnownPlatform::osx_64;
|
||||
#elif __arm64__
|
||||
return Platform::osx_arm64;
|
||||
return KnownPlatform::osx_arm64;
|
||||
#else
|
||||
#error "Unknown OSX platform"
|
||||
#endif
|
||||
|
||||
#elif defined(_WIN64)
|
||||
#if defined(_M_AMD64)
|
||||
return Platform::win_64;
|
||||
return KnownPlatform::win_64;
|
||||
#elif defined(_M_ARM64)
|
||||
return Platform::win_arm64;
|
||||
return KnownPlatform::win_arm64;
|
||||
#else
|
||||
#error "Unknown Windows platform"
|
||||
#endif
|
||||
#elif defined(_WIN32)
|
||||
return Platform::win_32;
|
||||
return KnownPlatform::win_32;
|
||||
|
||||
#else
|
||||
#error "Unknown platform"
|
||||
|
@ -97,12 +97,12 @@ namespace mamba::specs
|
|||
return platform_name(build_platform());
|
||||
}
|
||||
|
||||
void to_json(nlohmann::json& j, const Platform& p)
|
||||
void to_json(nlohmann::json& j, const KnownPlatform& p)
|
||||
{
|
||||
j = platform_name(p);
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json& j, Platform& p)
|
||||
void from_json(const nlohmann::json& j, KnownPlatform& p)
|
||||
{
|
||||
const auto j_str = j.get<std::string_view>();
|
||||
if (const auto maybe = platform_parse(j_str))
|
||||
|
|
|
@ -26,14 +26,14 @@ namespace mamba::specs
|
|||
{
|
||||
// Defined in conda_url.cpp
|
||||
[[nodiscard]] auto find_slash_and_platform(std::string_view path)
|
||||
-> std::tuple<std::size_t, std::size_t, std::optional<Platform>>;
|
||||
-> std::tuple<std::size_t, std::size_t, std::optional<KnownPlatform>>;
|
||||
|
||||
auto UnresolvedChannel::parse_platform_list(std::string_view plats) -> dynamic_platform_set
|
||||
auto UnresolvedChannel::parse_platform_list(std::string_view plats) -> platform_set
|
||||
{
|
||||
static constexpr auto is_not_sep = [](char c) -> bool
|
||||
{ return !util::contains(UnresolvedChannel::platform_separators, c); };
|
||||
|
||||
auto out = dynamic_platform_set{};
|
||||
auto out = platform_set{};
|
||||
auto head_rest = util::lstrip_if_parts(plats, is_not_sep);
|
||||
while (!head_rest.front().empty())
|
||||
{
|
||||
|
@ -49,9 +49,9 @@ namespace mamba::specs
|
|||
|
||||
namespace
|
||||
{
|
||||
using dynamic_platform_set = UnresolvedChannel::dynamic_platform_set;
|
||||
using dynamic_platform_set = UnresolvedChannel::platform_set;
|
||||
|
||||
auto parse_platform_path(std::string_view str) -> std::pair<std::string, std::string>
|
||||
auto parse_platform_path(std::string_view str) -> std::pair<std::string, DynamicPlatform>
|
||||
{
|
||||
static constexpr auto npos = std::string_view::npos;
|
||||
|
||||
|
@ -137,7 +137,7 @@ namespace mamba::specs
|
|||
}
|
||||
|
||||
auto location = std::string();
|
||||
auto filters = dynamic_platform_set();
|
||||
auto filters = platform_set();
|
||||
auto split_outcome = split_location_platform(str);
|
||||
if (split_outcome)
|
||||
{
|
||||
|
@ -173,7 +173,7 @@ namespace mamba::specs
|
|||
return { { std::move(location), std::move(filters), type } };
|
||||
}
|
||||
|
||||
UnresolvedChannel::UnresolvedChannel(std::string location, dynamic_platform_set filters, Type type)
|
||||
UnresolvedChannel::UnresolvedChannel(std::string location, platform_set filters, Type type)
|
||||
: m_location(std::move(location))
|
||||
, m_platform_filters(std::move(filters))
|
||||
, m_type(type)
|
||||
|
@ -212,17 +212,17 @@ namespace mamba::specs
|
|||
return std::exchange(m_location, "");
|
||||
}
|
||||
|
||||
auto UnresolvedChannel::platform_filters() const& -> const dynamic_platform_set&
|
||||
auto UnresolvedChannel::platform_filters() const& -> const platform_set&
|
||||
{
|
||||
return m_platform_filters;
|
||||
}
|
||||
|
||||
auto UnresolvedChannel::platform_filters() && -> dynamic_platform_set
|
||||
auto UnresolvedChannel::platform_filters() && -> platform_set
|
||||
{
|
||||
return std::move(m_platform_filters);
|
||||
}
|
||||
|
||||
auto UnresolvedChannel::clear_platform_filters() -> dynamic_platform_set
|
||||
auto UnresolvedChannel::clear_platform_filters() -> platform_set
|
||||
{
|
||||
return std::exchange(m_platform_filters, {});
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace mamba
|
|||
CHECK_EQ(pkg.build_string, "abcd");
|
||||
CHECK_EQ(pkg.build_number, 0);
|
||||
CHECK_EQ(pkg.channel, "@");
|
||||
CHECK_EQ(pkg.subdir, context.platform);
|
||||
CHECK_EQ(pkg.platform, context.platform);
|
||||
CHECK_EQ(pkg.md5, "12345678901234567890123456789012");
|
||||
CHECK_EQ(pkg.filename, pkg.name);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace
|
|||
auto out = specs::PackageInfo();
|
||||
out.name = std::move(name);
|
||||
out.version = std::move(version);
|
||||
out.depends = std::move(deps);
|
||||
out.dependencies = std::move(deps);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ TEST_SUITE("solver::libsolv::database")
|
|||
[&](const auto& p)
|
||||
{
|
||||
count++;
|
||||
CHECK(util::any_starts_with(p.depends, "x"));
|
||||
CHECK(util::any_starts_with(p.dependencies, "x"));
|
||||
}
|
||||
);
|
||||
CHECK_EQ(count, 1);
|
||||
|
@ -197,7 +197,7 @@ TEST_SUITE("solver::libsolv::database")
|
|||
[&](const specs::PackageInfo& pkg)
|
||||
{
|
||||
found_python = true;
|
||||
for (auto const& dep : pkg.depends)
|
||||
for (auto const& dep : pkg.dependencies)
|
||||
{
|
||||
CHECK_FALSE(util::contains(dep, "pip"));
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ TEST_SUITE("solver::libsolv::database")
|
|||
{
|
||||
found_python = true;
|
||||
auto found_pip = false;
|
||||
for (auto const& dep : pkg.depends)
|
||||
for (auto const& dep : pkg.dependencies)
|
||||
{
|
||||
found_pip |= util::contains(dep, "pip");
|
||||
}
|
||||
|
|
|
@ -359,7 +359,7 @@ TEST_SUITE("solver::libsolv::solver")
|
|||
SUBCASE("numpy 1.0 is installed with python 2.0 and foo")
|
||||
{
|
||||
auto pkg_numpy = specs::PackageInfo("numpy", "1.0.0", "phony", 0);
|
||||
pkg_numpy.depends = { "python=2.0", "foo" };
|
||||
pkg_numpy.dependencies = { "python=2.0", "foo" };
|
||||
const auto installed = db.add_repo_from_packages(std::array{
|
||||
pkg_numpy,
|
||||
specs::PackageInfo("python", "2.0.0", "phony", 0),
|
||||
|
@ -482,7 +482,7 @@ TEST_SUITE("solver::libsolv::solver")
|
|||
SUBCASE("numpy 1.0 is installed with python 4.0 and constrained foo")
|
||||
{
|
||||
auto pkg_numpy = specs::PackageInfo("numpy", "1.0.0", "phony", 0);
|
||||
pkg_numpy.depends = { "python=4.0", "foo" };
|
||||
pkg_numpy.dependencies = { "python=4.0", "foo" };
|
||||
auto pkg_foo = specs::PackageInfo("foo", "1.0.0", "phony", 0);
|
||||
pkg_foo.constrains = { "numpy=1.0.0", "foo" };
|
||||
const auto installed = db.add_repo_from_packages(std::array{
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace
|
|||
{
|
||||
auto pkg = specs::PackageInfo(std::move(name));
|
||||
pkg.version = std::move(version);
|
||||
pkg.depends = std::move(dependencies);
|
||||
pkg.dependencies = std::move(dependencies);
|
||||
pkg.build_string = "bld";
|
||||
return pkg;
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ TEST_SUITE("specs::CondaURL")
|
|||
CHECK_FALSE(url.platform().has_value());
|
||||
CHECK_EQ(url.platform_name(), "");
|
||||
|
||||
CHECK_THROWS_AS(url.set_platform(Platform::linux_64), std::invalid_argument);
|
||||
CHECK_THROWS_AS(url.set_platform(KnownPlatform::linux_64), std::invalid_argument);
|
||||
CHECK_EQ(url.path_without_token(), "/");
|
||||
CHECK_EQ(url.path(), "/");
|
||||
|
||||
|
@ -182,7 +182,7 @@ TEST_SUITE("specs::CondaURL")
|
|||
CHECK_FALSE(url.platform().has_value());
|
||||
CHECK_EQ(url.platform_name(), "");
|
||||
|
||||
CHECK_THROWS_AS(url.set_platform(Platform::linux_64), std::invalid_argument);
|
||||
CHECK_THROWS_AS(url.set_platform(KnownPlatform::linux_64), std::invalid_argument);
|
||||
CHECK_EQ(url.path(), "/conda-forge");
|
||||
|
||||
CHECK_FALSE(url.clear_platform());
|
||||
|
@ -196,7 +196,7 @@ TEST_SUITE("specs::CondaURL")
|
|||
CHECK_FALSE(url.platform().has_value());
|
||||
CHECK_EQ(url.platform_name(), "");
|
||||
|
||||
CHECK_THROWS_AS(url.set_platform(Platform::linux_64), std::invalid_argument);
|
||||
CHECK_THROWS_AS(url.set_platform(KnownPlatform::linux_64), std::invalid_argument);
|
||||
CHECK_EQ(url.path(), "/conda-forge/");
|
||||
|
||||
CHECK_FALSE(url.clear_platform());
|
||||
|
@ -207,11 +207,11 @@ TEST_SUITE("specs::CondaURL")
|
|||
{
|
||||
url.set_path("conda-forge/win-64");
|
||||
|
||||
CHECK_EQ(url.platform(), Platform::win_64);
|
||||
CHECK_EQ(url.platform(), KnownPlatform::win_64);
|
||||
CHECK_EQ(url.platform_name(), "win-64");
|
||||
|
||||
url.set_platform(Platform::linux_64);
|
||||
CHECK_EQ(url.platform(), Platform::linux_64);
|
||||
url.set_platform(KnownPlatform::linux_64);
|
||||
CHECK_EQ(url.platform(), KnownPlatform::linux_64);
|
||||
CHECK_EQ(url.path(), "/conda-forge/linux-64");
|
||||
|
||||
CHECK(url.clear_platform());
|
||||
|
@ -222,11 +222,11 @@ TEST_SUITE("specs::CondaURL")
|
|||
{
|
||||
url.set_path("conda-forge/OSX-64");
|
||||
|
||||
CHECK_EQ(url.platform(), Platform::osx_64);
|
||||
CHECK_EQ(url.platform(), KnownPlatform::osx_64);
|
||||
CHECK_EQ(url.platform_name(), "OSX-64"); // Captialization not changed
|
||||
|
||||
url.set_platform("Win-64");
|
||||
CHECK_EQ(url.platform(), Platform::win_64);
|
||||
CHECK_EQ(url.platform(), KnownPlatform::win_64);
|
||||
CHECK_EQ(url.path(), "/conda-forge/Win-64"); // Captialization not changed
|
||||
|
||||
CHECK(url.clear_platform());
|
||||
|
@ -237,11 +237,11 @@ TEST_SUITE("specs::CondaURL")
|
|||
{
|
||||
url.set_path("/conda-forge/linux-64/micromamba-1.5.1-0.tar.bz2");
|
||||
|
||||
CHECK_EQ(url.platform(), Platform::linux_64);
|
||||
CHECK_EQ(url.platform(), KnownPlatform::linux_64);
|
||||
CHECK_EQ(url.platform_name(), "linux-64");
|
||||
|
||||
url.set_platform("osx-64");
|
||||
CHECK_EQ(url.platform(), Platform::osx_64);
|
||||
CHECK_EQ(url.platform(), KnownPlatform::osx_64);
|
||||
CHECK_EQ(url.path(), "/conda-forge/osx-64/micromamba-1.5.1-0.tar.bz2");
|
||||
|
||||
CHECK(url.clear_platform());
|
||||
|
|
|
@ -371,7 +371,7 @@ TEST_SUITE("specs::match_spec")
|
|||
auto ms = MatchSpec::parse("conda-forge[noarch]::tzdata[subdir=linux64]").value();
|
||||
CHECK_EQ(ms.str(), "conda-forge[noarch]::tzdata");
|
||||
CHECK_EQ(ms.channel().value().str(), "conda-forge[noarch]");
|
||||
CHECK_EQ(ms.subdirs().value().get(), MatchSpec::subdir_list{ "noarch" });
|
||||
CHECK_EQ(ms.platforms().value().get(), MatchSpec::platform_set{ "noarch" });
|
||||
CHECK_EQ(ms.name().str(), "tzdata");
|
||||
CHECK(ms.version().is_explicitly_free());
|
||||
CHECK(ms.build_string().is_free());
|
||||
|
@ -382,7 +382,7 @@ TEST_SUITE("specs::match_spec")
|
|||
auto ms = MatchSpec::parse("conda-forge::tzdata[subdir=mamba-37]").value();
|
||||
CHECK_EQ(ms.str(), "conda-forge[mamba-37]::tzdata");
|
||||
CHECK_EQ(ms.channel().value().str(), "conda-forge[mamba-37]");
|
||||
CHECK_EQ(ms.subdirs().value().get(), MatchSpec::subdir_list{ "mamba-37" });
|
||||
CHECK_EQ(ms.platforms().value().get(), MatchSpec::platform_set{ "mamba-37" });
|
||||
CHECK_EQ(ms.name().str(), "tzdata");
|
||||
CHECK(ms.version().is_explicitly_free());
|
||||
CHECK(ms.build_string().is_free());
|
||||
|
@ -395,7 +395,7 @@ TEST_SUITE("specs::match_spec")
|
|||
)
|
||||
.value();
|
||||
CHECK_EQ(ms.channel().value().str(), "conda-canary[linux-64]");
|
||||
CHECK_EQ(ms.subdirs().value().get(), MatchSpec::subdir_list{ "linux-64" });
|
||||
CHECK_EQ(ms.platforms().value().get(), MatchSpec::platform_set{ "linux-64" });
|
||||
CHECK_EQ(ms.name().str(), "conda");
|
||||
CHECK_EQ(ms.version().str(), "==4.3.21.0post699+1dab973"); // Not ``.0post`` diff
|
||||
CHECK_EQ(ms.build_string().str(), "py36h4a561cd_0");
|
||||
|
|
|
@ -33,7 +33,7 @@ TEST_SUITE("specs::package_info")
|
|||
CHECK_EQ(pkg.filename, "pkg-6.4-bld.conda");
|
||||
CHECK_EQ(pkg.package_url, url);
|
||||
CHECK_EQ(pkg.md5, "");
|
||||
CHECK_EQ(pkg.subdir, "linux-64");
|
||||
CHECK_EQ(pkg.platform, "linux-64");
|
||||
CHECK_EQ(pkg.channel, "https://conda.anaconda.org/conda-forge");
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ TEST_SUITE("specs::package_info")
|
|||
CHECK_EQ(pkg.filename, "pkg-6.4-bld.conda");
|
||||
CHECK_EQ(pkg.package_url, url.substr(0, url.rfind('#')));
|
||||
CHECK_EQ(pkg.md5, url.substr(url.rfind('#') + 1));
|
||||
CHECK_EQ(pkg.subdir, "linux-64");
|
||||
CHECK_EQ(pkg.platform, "linux-64");
|
||||
CHECK_EQ(pkg.channel, "https://conda.anaconda.org/conda-forge");
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ TEST_SUITE("specs::package_info")
|
|||
pkg.noarch = NoArchType::Generic;
|
||||
pkg.channel = "conda-forge";
|
||||
pkg.package_url = "https://repo.mamba.pm/conda-forge/linux-64/foo-4.0-mybld.conda";
|
||||
pkg.subdir = "linux-64";
|
||||
pkg.platform = "linux-64";
|
||||
pkg.filename = "foo-4.0-mybld.conda";
|
||||
pkg.license = "MIT";
|
||||
pkg.size = 3200;
|
||||
|
@ -81,7 +81,7 @@ TEST_SUITE("specs::package_info")
|
|||
pkg.sha256 = "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b";
|
||||
pkg.md5 = "68b329da9893e34099c7d8ad5cb9c940";
|
||||
pkg.track_features = { "mkl", "blas" };
|
||||
pkg.depends = { "python>=3.7", "requests" };
|
||||
pkg.dependencies = { "python>=3.7", "requests" };
|
||||
pkg.constrains = { "pip>=2.1" };
|
||||
|
||||
SUBCASE("field")
|
||||
|
|
|
@ -12,20 +12,20 @@ using namespace mamba::specs;
|
|||
|
||||
TEST_SUITE("specs::platform")
|
||||
{
|
||||
TEST_CASE("Platform")
|
||||
TEST_CASE("KnownPlatform")
|
||||
{
|
||||
SUBCASE("name")
|
||||
{
|
||||
CHECK_EQ(platform_name(Platform::linux_riscv32), "linux-riscv32");
|
||||
CHECK_EQ(platform_name(Platform::osx_arm64), "osx-arm64");
|
||||
CHECK_EQ(platform_name(Platform::win_64), "win-64");
|
||||
CHECK_EQ(platform_name(KnownPlatform::linux_riscv32), "linux-riscv32");
|
||||
CHECK_EQ(platform_name(KnownPlatform::osx_arm64), "osx-arm64");
|
||||
CHECK_EQ(platform_name(KnownPlatform::win_64), "win-64");
|
||||
}
|
||||
|
||||
SUBCASE("parse")
|
||||
{
|
||||
CHECK_EQ(platform_parse("linux-armv6l"), Platform::linux_armv6l);
|
||||
CHECK_EQ(platform_parse(" win-32 "), Platform::win_32);
|
||||
CHECK_EQ(platform_parse(" OSX-64"), Platform::osx_64);
|
||||
CHECK_EQ(platform_parse("linux-armv6l"), KnownPlatform::linux_armv6l);
|
||||
CHECK_EQ(platform_parse(" win-32 "), KnownPlatform::win_32);
|
||||
CHECK_EQ(platform_parse(" OSX-64"), KnownPlatform::osx_64);
|
||||
CHECK_EQ(platform_parse("linus-46"), std::nullopt);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ TEST_SUITE("specs::repo_data")
|
|||
{
|
||||
auto data = RepoData();
|
||||
data.version = 1;
|
||||
data.info = ChannelInfo{ /* .subdir= */ Platform::linux_64 };
|
||||
data.info = ChannelInfo{ /* .subdir= */ KnownPlatform::linux_64 };
|
||||
data.packages = {
|
||||
{ "mamba-1.0-h12345.tar.bz2", RepoDataPackage{ "mamba" } },
|
||||
{ "conda-1.0-h54321.tar.bz2", RepoDataPackage{ "conda" } },
|
||||
|
|
|
@ -59,29 +59,29 @@ namespace mambapy
|
|||
[](const mamba::fs::u8path& p) { return strip_archive_extension(p); }
|
||||
);
|
||||
|
||||
py::enum_<Platform>(m, "Platform")
|
||||
.value("noarch", Platform::noarch)
|
||||
.value("linux_32", Platform::linux_32)
|
||||
.value("linux_64", Platform::linux_64)
|
||||
.value("linux_armv6l", Platform::linux_armv6l)
|
||||
.value("linux_armv7l", Platform::linux_armv7l)
|
||||
.value("linux_aarch64", Platform::linux_aarch64)
|
||||
.value("linux_ppc64le", Platform::linux_ppc64le)
|
||||
.value("linux_ppc64", Platform::linux_ppc64)
|
||||
.value("linux_s390x", Platform::linux_s390x)
|
||||
.value("linux_riscv32", Platform::linux_riscv32)
|
||||
.value("linux_riscv64", Platform::linux_riscv64)
|
||||
.value("osx_64", Platform::osx_64)
|
||||
.value("osx_arm64", Platform::osx_arm64)
|
||||
.value("win_32", Platform::win_32)
|
||||
.value("win_64", Platform::win_64)
|
||||
.value("win_arm64", Platform::win_arm64)
|
||||
.value("zos_z", Platform::zos_z)
|
||||
.def(py::init(&enum_from_str<Platform>))
|
||||
py::enum_<KnownPlatform>(m, "KnownPlatform")
|
||||
.value("noarch", KnownPlatform::noarch)
|
||||
.value("linux_32", KnownPlatform::linux_32)
|
||||
.value("linux_64", KnownPlatform::linux_64)
|
||||
.value("linux_armv6l", KnownPlatform::linux_armv6l)
|
||||
.value("linux_armv7l", KnownPlatform::linux_armv7l)
|
||||
.value("linux_aarch64", KnownPlatform::linux_aarch64)
|
||||
.value("linux_ppc64le", KnownPlatform::linux_ppc64le)
|
||||
.value("linux_ppc64", KnownPlatform::linux_ppc64)
|
||||
.value("linux_s390x", KnownPlatform::linux_s390x)
|
||||
.value("linux_riscv32", KnownPlatform::linux_riscv32)
|
||||
.value("linux_riscv64", KnownPlatform::linux_riscv64)
|
||||
.value("osx_64", KnownPlatform::osx_64)
|
||||
.value("osx_arm64", KnownPlatform::osx_arm64)
|
||||
.value("win_32", KnownPlatform::win_32)
|
||||
.value("win_64", KnownPlatform::win_64)
|
||||
.value("win_arm64", KnownPlatform::win_arm64)
|
||||
.value("zos_z", KnownPlatform::zos_z)
|
||||
.def(py::init(&enum_from_str<KnownPlatform>))
|
||||
.def_static("parse", &platform_parse)
|
||||
.def_static("count", &known_platforms_count)
|
||||
.def_static("build_platform", &build_platform);
|
||||
py::implicitly_convertible<py::str, Platform>();
|
||||
py::implicitly_convertible<py::str, KnownPlatform>();
|
||||
|
||||
py::enum_<NoArchType>(m, "NoArchType")
|
||||
.value("No", NoArchType::No)
|
||||
|
@ -259,7 +259,7 @@ namespace mambapy
|
|||
)
|
||||
.def("clear_path_without_token", &CondaURL::clear_path_without_token)
|
||||
.def("platform", &CondaURL::platform)
|
||||
.def("set_platform", [](CondaURL& self, Platform plat) { self.set_platform(plat); })
|
||||
.def("set_platform", [](CondaURL& self, KnownPlatform plat) { self.set_platform(plat); })
|
||||
.def("clear_platform", &CondaURL::clear_platform)
|
||||
.def(
|
||||
"package",
|
||||
|
@ -321,8 +321,7 @@ namespace mambapy
|
|||
py_channel_spec //
|
||||
.def_static("parse", UnresolvedChannel::parse)
|
||||
.def(
|
||||
py::init<std::string, UnresolvedChannel::dynamic_platform_set, UnresolvedChannel::Type>(
|
||||
),
|
||||
py::init<std::string, UnresolvedChannel::platform_set, UnresolvedChannel::Type>(),
|
||||
py::arg("location"),
|
||||
py::arg("platform_filters"),
|
||||
py::arg("type") = UnresolvedChannel::Type::Unknown
|
||||
|
@ -603,14 +602,14 @@ namespace mambapy
|
|||
decltype(PackageInfo::build_number) build_number,
|
||||
decltype(PackageInfo::channel) channel,
|
||||
decltype(PackageInfo::package_url) package_url,
|
||||
decltype(PackageInfo::subdir) subdir,
|
||||
decltype(PackageInfo::platform) platform,
|
||||
decltype(PackageInfo::filename) filename,
|
||||
decltype(PackageInfo::license) license,
|
||||
decltype(PackageInfo::md5) md5,
|
||||
decltype(PackageInfo::sha256) sha256,
|
||||
decltype(PackageInfo::signatures) signatures,
|
||||
decltype(PackageInfo::track_features) track_features,
|
||||
decltype(PackageInfo::depends) depends,
|
||||
decltype(PackageInfo::dependencies) depends,
|
||||
decltype(PackageInfo::constrains) constrains,
|
||||
decltype(PackageInfo::defaulted_keys) defaulted_keys,
|
||||
decltype(PackageInfo::noarch) noarch,
|
||||
|
@ -624,14 +623,14 @@ namespace mambapy
|
|||
pkg.build_number = std::move(build_number);
|
||||
pkg.channel = channel;
|
||||
pkg.package_url = package_url;
|
||||
pkg.subdir = subdir;
|
||||
pkg.platform = platform;
|
||||
pkg.filename = filename;
|
||||
pkg.license = license;
|
||||
pkg.md5 = md5;
|
||||
pkg.sha256 = sha256;
|
||||
pkg.signatures = signatures;
|
||||
pkg.track_features = track_features;
|
||||
pkg.depends = depends;
|
||||
pkg.dependencies = depends;
|
||||
pkg.constrains = constrains;
|
||||
pkg.defaulted_keys = defaulted_keys;
|
||||
pkg.noarch = noarch;
|
||||
|
@ -646,14 +645,14 @@ namespace mambapy
|
|||
py::arg("build_number") = decltype(PackageInfo::build_number)(),
|
||||
py::arg("channel") = decltype(PackageInfo::channel)(),
|
||||
py::arg("package_url") = decltype(PackageInfo::package_url)(),
|
||||
py::arg("subdir") = decltype(PackageInfo::subdir)(),
|
||||
py::arg("platform") = decltype(PackageInfo::platform)(),
|
||||
py::arg("filename") = decltype(PackageInfo::filename)(),
|
||||
py::arg("license") = decltype(PackageInfo::license)(),
|
||||
py::arg("md5") = decltype(PackageInfo::md5)(),
|
||||
py::arg("sha256") = decltype(PackageInfo::sha256)(),
|
||||
py::arg("signatures") = decltype(PackageInfo::signatures)(),
|
||||
py::arg("track_features") = decltype(PackageInfo::track_features)(),
|
||||
py::arg("depends") = decltype(PackageInfo::depends)(),
|
||||
py::arg("depends") = decltype(PackageInfo::dependencies)(),
|
||||
py::arg("constrains") = decltype(PackageInfo::constrains)(),
|
||||
py::arg("defaulted_keys") = decltype(PackageInfo::defaulted_keys)(),
|
||||
py::arg("noarch") = decltype(PackageInfo::noarch)(),
|
||||
|
@ -674,7 +673,7 @@ namespace mambapy
|
|||
[](py::handle, py::handle)
|
||||
{ throw std::runtime_error("'url' has been renamed 'package_url'"); }
|
||||
)
|
||||
.def_readwrite("subdir", &PackageInfo::subdir)
|
||||
.def_readwrite("platform", &PackageInfo::platform)
|
||||
.def_readwrite("filename", &PackageInfo::filename)
|
||||
.def_property(
|
||||
// V2 migration helper
|
||||
|
@ -689,7 +688,7 @@ namespace mambapy
|
|||
.def_readwrite("md5", &PackageInfo::md5)
|
||||
.def_readwrite("sha256", &PackageInfo::sha256)
|
||||
.def_readwrite("track_features", &PackageInfo::track_features)
|
||||
.def_readwrite("depends", &PackageInfo::depends)
|
||||
.def_readwrite("dependencies", &PackageInfo::dependencies)
|
||||
.def_readwrite("constrains", &PackageInfo::constrains)
|
||||
.def_readwrite("signatures", &PackageInfo::signatures)
|
||||
.def_readwrite("defaulted_keys", &PackageInfo::defaulted_keys)
|
||||
|
@ -740,7 +739,7 @@ namespace mambapy
|
|||
)
|
||||
.def_property("channel", &MatchSpec::channel, &MatchSpec::set_channel)
|
||||
.def_property("filename", &MatchSpec::filename, &MatchSpec::set_filename)
|
||||
.def_property("subdirs", &MatchSpec::subdirs, &MatchSpec::set_subdirs)
|
||||
.def_property("platforms", &MatchSpec::platforms, &MatchSpec::set_platforms)
|
||||
.def_property("name_space", &MatchSpec::name_space, &MatchSpec::set_name_space)
|
||||
.def_property("name", &MatchSpec::name, &MatchSpec::set_name)
|
||||
.def_property("version", &MatchSpec::version, &MatchSpec::set_version)
|
||||
|
|
|
@ -137,7 +137,7 @@ def test_Database_RepoInfo_from_packages(add_pip_as_python_dependency):
|
|||
pkgs = db.packages_in_repo(repo)
|
||||
assert len(pkgs) == 1
|
||||
assert pkgs[0].name == "python"
|
||||
assert pkgs[0].depends == [] if add_pip_as_python_dependency else ["pip"]
|
||||
assert pkgs[0].dependencies == [] if add_pip_as_python_dependency else ["pip"]
|
||||
|
||||
db.remove_repo(repo)
|
||||
assert db.repo_count() == 0
|
||||
|
@ -202,7 +202,7 @@ def test_Database_RepoInfo_from_repodata(
|
|||
pkgs = db.packages_in_repo(repo)
|
||||
assert len(pkgs) == repo.package_count()
|
||||
assert pkgs[0].name == "python"
|
||||
assert pkgs[0].depends == [] if add_pip_as_python_dependency else ["pip"]
|
||||
assert pkgs[0].dependencies == [] if add_pip_as_python_dependency else ["pip"]
|
||||
|
||||
# Native serialize repo
|
||||
solv_file = tmp_path / "repodata.solv"
|
||||
|
|
|
@ -9,14 +9,14 @@ def test_import_submodule():
|
|||
import libmambapy.specs as specs
|
||||
|
||||
# Dummy execution
|
||||
_p = specs.Platform.noarch
|
||||
_p = specs.KnownPlatform.noarch
|
||||
|
||||
|
||||
def test_import_recursive():
|
||||
import libmambapy as mamba
|
||||
|
||||
# Dummy execution
|
||||
_p = mamba.specs.Platform.noarch
|
||||
_p = mamba.specs.KnownPlatform.noarch
|
||||
|
||||
|
||||
def test_ParseError():
|
||||
|
@ -33,35 +33,35 @@ def test_archive_extension():
|
|||
assert libmambapy.specs.strip_archive_extension("conda.pkg") == "conda.pkg"
|
||||
|
||||
|
||||
def test_Platform():
|
||||
Platform = libmambapy.specs.Platform
|
||||
def test_KnownPlatform():
|
||||
KnownPlatform = libmambapy.specs.KnownPlatform
|
||||
|
||||
assert Platform.noarch.name == "noarch"
|
||||
assert Platform.linux_32.name == "linux_32"
|
||||
assert Platform.linux_64.name == "linux_64"
|
||||
assert Platform.linux_armv6l.name == "linux_armv6l"
|
||||
assert Platform.linux_armv7l.name == "linux_armv7l"
|
||||
assert Platform.linux_aarch64.name == "linux_aarch64"
|
||||
assert Platform.linux_ppc64le.name == "linux_ppc64le"
|
||||
assert Platform.linux_ppc64.name == "linux_ppc64"
|
||||
assert Platform.linux_s390x.name == "linux_s390x"
|
||||
assert Platform.linux_riscv32.name == "linux_riscv32"
|
||||
assert Platform.linux_riscv64.name == "linux_riscv64"
|
||||
assert Platform.osx_64.name == "osx_64"
|
||||
assert Platform.osx_arm64.name == "osx_arm64"
|
||||
assert Platform.win_32.name == "win_32"
|
||||
assert Platform.win_64.name == "win_64"
|
||||
assert Platform.win_arm64.name == "win_arm64"
|
||||
assert Platform.zos_z.name == "zos_z"
|
||||
assert KnownPlatform.noarch.name == "noarch"
|
||||
assert KnownPlatform.linux_32.name == "linux_32"
|
||||
assert KnownPlatform.linux_64.name == "linux_64"
|
||||
assert KnownPlatform.linux_armv6l.name == "linux_armv6l"
|
||||
assert KnownPlatform.linux_armv7l.name == "linux_armv7l"
|
||||
assert KnownPlatform.linux_aarch64.name == "linux_aarch64"
|
||||
assert KnownPlatform.linux_ppc64le.name == "linux_ppc64le"
|
||||
assert KnownPlatform.linux_ppc64.name == "linux_ppc64"
|
||||
assert KnownPlatform.linux_s390x.name == "linux_s390x"
|
||||
assert KnownPlatform.linux_riscv32.name == "linux_riscv32"
|
||||
assert KnownPlatform.linux_riscv64.name == "linux_riscv64"
|
||||
assert KnownPlatform.osx_64.name == "osx_64"
|
||||
assert KnownPlatform.osx_arm64.name == "osx_arm64"
|
||||
assert KnownPlatform.win_32.name == "win_32"
|
||||
assert KnownPlatform.win_64.name == "win_64"
|
||||
assert KnownPlatform.win_arm64.name == "win_arm64"
|
||||
assert KnownPlatform.zos_z.name == "zos_z"
|
||||
|
||||
assert len(Platform.__members__) == Platform.count()
|
||||
assert Platform.build_platform() in Platform.__members__.values()
|
||||
assert Platform.parse("linux-64") == Platform.linux_64
|
||||
assert Platform("linux_64") == Platform.linux_64
|
||||
assert len(KnownPlatform.__members__) == KnownPlatform.count()
|
||||
assert KnownPlatform.build_platform() in KnownPlatform.__members__.values()
|
||||
assert KnownPlatform.parse("linux-64") == KnownPlatform.linux_64
|
||||
assert KnownPlatform("linux_64") == KnownPlatform.linux_64
|
||||
|
||||
with pytest.raises(KeyError):
|
||||
# No parsing, explicit name
|
||||
Platform("linux-64")
|
||||
KnownPlatform("linux-64")
|
||||
|
||||
|
||||
def test_NoArchType():
|
||||
|
@ -161,7 +161,7 @@ def test_CondaURL_setters():
|
|||
url.set_path_without_token("bar%20", encode=False)
|
||||
assert url.path_without_token() == "/bar "
|
||||
assert url.clear_path_without_token()
|
||||
# Platform
|
||||
# KnownPlatform
|
||||
url.set_path_without_token("conda-forge/win-64", encode=False)
|
||||
assert url.platform().name == "win_64"
|
||||
url.set_platform("linux_64")
|
||||
|
@ -750,8 +750,8 @@ def test_PackageInfo():
|
|||
assert pkg.channel == "conda-forge"
|
||||
pkg.package_url = "https://repo.mamba.pm/conda-forge/linux-64/foo-4.0-mybld.conda"
|
||||
assert pkg.package_url == "https://repo.mamba.pm/conda-forge/linux-64/foo-4.0-mybld.conda"
|
||||
pkg.subdir = "linux-64"
|
||||
assert pkg.subdir == "linux-64"
|
||||
pkg.platform = "linux-64"
|
||||
assert pkg.platform == "linux-64"
|
||||
pkg.filename = "foo-4.0-mybld.conda"
|
||||
assert pkg.filename == "foo-4.0-mybld.conda"
|
||||
pkg.license = "MIT"
|
||||
|
@ -766,8 +766,8 @@ def test_PackageInfo():
|
|||
assert pkg.md5 == "68b329da9893e34099c7d8ad5cb9c940"
|
||||
pkg.track_features = ["mkl"]
|
||||
assert pkg.track_features == ["mkl"]
|
||||
pkg.depends = ["python>=3.7"]
|
||||
assert pkg.depends == ["python>=3.7"]
|
||||
pkg.dependencies = ["python>=3.7"]
|
||||
assert pkg.dependencies == ["python>=3.7"]
|
||||
pkg.constrains = ["pip>=2.1"]
|
||||
assert pkg.constrains == ["pip>=2.1"]
|
||||
|
||||
|
@ -844,7 +844,7 @@ def test_MatchSpec():
|
|||
)
|
||||
|
||||
assert str(ms.channel) == "conda-forge[plat]"
|
||||
assert ms.subdirs == {"plat"}
|
||||
assert ms.platforms == {"plat"}
|
||||
assert ms.name_space == "ns"
|
||||
assert str(ms.name) == "python"
|
||||
assert str(ms.version) == "=3.7"
|
||||
|
|
|
@ -197,7 +197,7 @@ set_env_command(CLI::App* com, Configuration& config)
|
|||
dependencies
|
||||
// If the size is not one, it's a custom mutli channel
|
||||
<< ((chans.size() == 1) ? chans.front().display_name() : v.channel)
|
||||
<< "/" << v.subdir << "::";
|
||||
<< "/" << v.platform << "::";
|
||||
}
|
||||
dependencies << v.name << "=" << v.version;
|
||||
if (!no_build)
|
||||
|
|
Loading…
Reference in New Issue