Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subdir renaming #3214

Merged
merged 8 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libmamba/include/mamba/specs/build_number_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions libmamba/include/mamba/specs/conda_url.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions libmamba/include/mamba/specs/match_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[';
Expand All @@ -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);
Expand Down Expand Up @@ -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 = {};
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libmamba/include/mamba/specs/package_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
60 changes: 31 additions & 29 deletions libmamba/include/mamba/specs/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion libmamba/include/mamba/specs/repo_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ namespace mamba::specs
struct ChannelInfo
{
/** The channel's subdirectory. */
Platform subdir = {};
KnownPlatform subdir = {};
};

/** Serialize to JSON. */
Expand Down
15 changes: 8 additions & 7 deletions libmamba/include/mamba/specs/unresolved_channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -87,31 +88,31 @@ 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;

[[nodiscard]] auto location() const& -> const std::string&;
[[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;
};
}
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/api/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions libmamba/src/core/env_lockfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/core/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/core/package_fetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions libmamba/src/core/prefix_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
10 changes: 5 additions & 5 deletions libmamba/src/core/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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]))
{
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/core/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/core/virtual_packages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading
Loading