Skip to content

Commit

Permalink
python: Adapt bindings accordingly
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
  • Loading branch information
jjerphan committed Aug 1, 2024
1 parent 0b09415 commit 6b8d197
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
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"));
}
}
12 changes: 1 addition & 11 deletions libmambapy/src/libmambapy/bindings/solver_libsolv.cpp
Original file line number Diff line number Diff line change
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

0 comments on commit 6b8d197

Please sign in to comment.