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

maint: Move solver::libsolv::RepoInfo to solver::RepoInfo #3380

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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 docs/source/usage/solver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Populating the Package Database
-------------------------------
The first thing needed is a |Database| of all the packages and their dependencies.
Packages are organised in repositories, described by a
:cpp:type:`RepoInfo <mamba::solver::libsolv::RepoInfo>`.
:cpp:type:`RepoInfo <mamba::solver::RepoInfo>`.
This serves to resolve explicit channel requirements or channel priority.
As such, the database constructor takes a set of
:cpp:type:`ChannelResolveParams <mamba::specs::ChannelResolveParams>`
Expand Down
4 changes: 2 additions & 2 deletions libmamba/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ set(
# Solver generic interface
${LIBMAMBA_SOURCE_DIR}/solver/helpers.cpp
${LIBMAMBA_SOURCE_DIR}/solver/problems_graph.cpp
${LIBMAMBA_SOURCE_DIR}/solver/repo_info.cpp
# Solver libsolv implementation
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/database.cpp
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/helpers.cpp
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/matcher.cpp
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/parameters.cpp
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/repo_info.cpp
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/solver.cpp
${LIBMAMBA_SOURCE_DIR}/solver/libsolv/unsolvable.cpp
# Artifacts validation
Expand Down Expand Up @@ -323,12 +323,12 @@ set(
${LIBMAMBA_INCLUDE_DIR}/mamba/specs/version_spec.hpp
# Solver generic interface
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/problems_graph.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/repo_info.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/request.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/solution.hpp
# Solver libsolv implementation
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/libsolv/database.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/libsolv/parameters.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/libsolv/repo_info.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/libsolv/solver.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/solver/libsolv/unsolvable.hpp
# Artifacts validation
Expand Down
6 changes: 3 additions & 3 deletions libmamba/include/mamba/core/package_database_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define MAMBA_CORE_PACKAGE_DATABASE_LOADER_HPP

#include "mamba/core/error_handling.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/specs/channel.hpp"

namespace mamba
Expand All @@ -28,12 +28,12 @@ namespace mamba
const Context& ctx,
solver::libsolv::Database& db,
const SubdirData& subdir
) -> expected_t<solver::libsolv::RepoInfo>;
) -> expected_t<solver::RepoInfo>;

auto load_installed_packages_in_database(
const Context& ctx,
solver::libsolv::Database& db,
const PrefixData& prefix
) -> solver::libsolv::RepoInfo;
) -> solver::RepoInfo;
}
#endif
2 changes: 1 addition & 1 deletion libmamba/include/mamba/solver/libsolv/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "mamba/core/error_handling.hpp"
#include "mamba/solver/libsolv/parameters.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/specs/channel.hpp"
#include "mamba/specs/package_info.hpp"
#include "mamba/util/loop_control.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ extern "C"
using Repo = struct s_Repo;
}

namespace mamba::solver::libsolv
namespace mamba::solver
{
class Database;
namespace libsolv
{
class Database;
}

/**
* A libsolv repository descriptor.
Expand Down Expand Up @@ -50,15 +53,15 @@ namespace mamba::solver::libsolv

[[nodiscard]] auto package_count() const -> std::size_t;

[[nodiscard]] auto priority() const -> Priorities;
[[nodiscard]] auto priority() const -> libsolv::Priorities;

private:

::Repo* m_ptr = nullptr; // This is a view managed by libsolv pool

explicit RepoInfo(::Repo* repo);

friend class Database;
friend class mamba::solver::libsolv::Database;
friend auto operator==(RepoInfo lhs, RepoInfo rhs) -> bool;
};

Expand Down
6 changes: 3 additions & 3 deletions libmamba/src/api/channel_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "mamba/core/prefix_data.hpp"
#include "mamba/core/subdirdata.hpp"
#include "mamba/solver/libsolv/database.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/specs/package_info.hpp"

namespace mamba
Expand All @@ -24,7 +24,7 @@ namespace mamba
ChannelContext& channel_context,
solver::libsolv::Database& pool,
const fs::u8path& pkgs_dir
) -> solver::libsolv::RepoInfo
) -> solver::RepoInfo
{
if (!fs::exists(pkgs_dir))
{
Expand Down Expand Up @@ -235,7 +235,7 @@ namespace mamba
}

load_subdir_in_database(ctx, pool, subdir)
.transform([&](solver::libsolv::RepoInfo&& repo)
.transform([&](solver::RepoInfo&& repo)
{ pool.set_repo_priority(repo, priorities[i]); })
.or_else(
[&](const auto&)
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/api/remove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "mamba/core/package_database_loader.hpp"
#include "mamba/core/prefix_data.hpp"
#include "mamba/core/transaction.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/libsolv/solver.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/solver/request.hpp"

namespace mamba
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/api/repoquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "mamba/core/package_database_loader.hpp"
#include "mamba/core/prefix_data.hpp"
#include "mamba/solver/libsolv/database.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/util/string.hpp"

namespace mamba
Expand Down
8 changes: 4 additions & 4 deletions libmamba/src/core/package_database_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "mamba/core/subdirdata.hpp"
#include "mamba/core/virtual_packages.hpp"
#include "mamba/solver/libsolv/database.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/util/build.hpp"
#include "mamba/util/string.hpp"

Expand Down Expand Up @@ -54,7 +54,7 @@ namespace mamba

auto
load_subdir_in_database(const Context& ctx, solver::libsolv::Database& db, const SubdirData& subdir)
-> expected_t<solver::libsolv::RepoInfo>
-> expected_t<solver::RepoInfo>
{
const auto expected_cache_origin = solver::libsolv::RepodataOrigin{
/* .url= */ util::rsplit(subdir.metadata().url(), "/", 1).front(),
Expand Down Expand Up @@ -110,7 +110,7 @@ namespace mamba
}
)
.transform(
[&](solver::libsolv::RepoInfo&& repo) -> solver::libsolv::RepoInfo
[&](solver::RepoInfo&& repo) -> solver::RepoInfo
{
if (!util::on_win)
{
Expand All @@ -134,7 +134,7 @@ namespace mamba
const Context& ctx,
solver::libsolv::Database& db,
const PrefixData& prefix
) -> solver::libsolv::RepoInfo
) -> solver::RepoInfo
{
// TODO(C++20): We could do a PrefixData range that returns packages without storing thems.
auto pkgs = prefix.sorted_records();
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/solver/libsolv/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "mamba/fs/filesystem.hpp"
#include "mamba/solver/libsolv/database.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/specs/match_spec.hpp"
#include "mamba/util/random.hpp"
#include "solv-cpp/pool.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#include <string_view>
#include <type_traits>

#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/repo_info.hpp"
#include "solv-cpp/repo.hpp"

namespace mamba::solver::libsolv
namespace mamba::solver
{
RepoInfo::RepoInfo(::Repo* repo)
: m_ptr(repo)
Expand All @@ -22,9 +22,9 @@ namespace mamba::solver::libsolv
return solv::ObjRepoViewConst(*m_ptr).name();
}

auto RepoInfo::priority() const -> Priorities
auto RepoInfo::priority() const -> libsolv::Priorities
{
static_assert(std::is_same_v<decltype(m_ptr->priority), Priorities::value_type>);
static_assert(std::is_same_v<decltype(m_ptr->priority), libsolv::Priorities::value_type>);
return { /* .priority= */ m_ptr->priority, /* .subpriority= */ m_ptr->subpriority };
}

Expand Down
2 changes: 1 addition & 1 deletion libmamba/tests/src/solver/test_problems_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "mamba/core/util.hpp"
#include "mamba/fs/filesystem.hpp"
#include "mamba/solver/libsolv/database.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/libsolv/solver.hpp"
#include "mamba/solver/libsolv/unsolvable.hpp"
#include "mamba/solver/problems_graph.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/specs/package_info.hpp"
#include "mamba/util/string.hpp"

Expand Down
3 changes: 1 addition & 2 deletions libmambapy/src/libmambapy/bindings/legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,7 @@ bind_submodule_impl(pybind11::module_ m)
py::class_<SubdirData>(m, "SubdirData")
.def(
"create_repo",
[](SubdirData& self, Context& context, solver::libsolv::Database& db
) -> solver::libsolv::RepoInfo
[](SubdirData& self, Context& context, solver::libsolv::Database& db) -> solver::RepoInfo
{
deprecated("Use libmambapy.load_subdir_in_database instead", "2.0");
return extract(load_subdir_in_database(context, db, self));
Expand Down
11 changes: 11 additions & 0 deletions libmambapy/src/libmambapy/bindings/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <pybind11/stl_bind.h>

#include "mamba/solver/problems_graph.hpp"
#include "mamba/solver/repo_info.hpp"
#include "mamba/solver/request.hpp"
#include "mamba/solver/solution.hpp"

Expand Down Expand Up @@ -507,5 +508,15 @@ namespace mambapy
}
)
.def("tree_message", &problem_tree_msg, py::arg("format") = ProblemsMessageFormat());

py::class_<RepoInfo>(m, "RepoInfo")
.def_property_readonly("id", &RepoInfo::id)
.def_property_readonly("name", &RepoInfo::name)
.def_property_readonly("priority", &RepoInfo::priority)
.def("package_count", &RepoInfo::package_count)
.def(py::self == py::self)
.def(py::self != py::self)
.def("__copy__", &copy<RepoInfo>)
.def("__deepcopy__", &deepcopy<RepoInfo>, py::arg("memo"));
}
}
14 changes: 2 additions & 12 deletions libmambapy/src/libmambapy/bindings/solver_libsolv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include "mamba/solver/libsolv/database.hpp"
#include "mamba/solver/libsolv/parameters.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/solver/libsolv/solver.hpp"
#include "mamba/solver/libsolv/unsolvable.hpp"
#include "mamba/solver/repo_info.hpp"

#include "bind_utils.hpp"
#include "bindings.hpp"
Expand Down Expand Up @@ -106,16 +106,6 @@ namespace mambapy
.def("__copy__", &copy<RepodataOrigin>)
.def("__deepcopy__", &deepcopy<RepodataOrigin>, py::arg("memo"));

py::class_<RepoInfo>(m, "RepoInfo")
.def_property_readonly("id", &RepoInfo::id)
.def_property_readonly("name", &RepoInfo::name)
.def_property_readonly("priority", &RepoInfo::priority)
.def("package_count", &RepoInfo::package_count)
.def(py::self == py::self)
.def(py::self != py::self)
.def("__copy__", &copy<RepoInfo>)
.def("__deepcopy__", &deepcopy<RepoInfo>, py::arg("memo"));

py::class_<Database>(m, "Database")
.def(py::init<specs::ChannelResolveParams>(), py::arg("channel_params"))
.def("set_logger", &Database::set_logger, py::call_guard<py::gil_scoped_acquire>())
Expand Down Expand Up @@ -169,7 +159,7 @@ namespace mambapy
.def("package_count", &Database::package_count)
.def(
"packages_in_repo",
[](const Database& db, RepoInfo repo)
[](const Database& db, solver::RepoInfo repo)
{
// TODO(C++20): When Database function are refactored to use range, take the
// opportunity here to make a Python iterator to avoid large alloc.
Expand Down
Loading