mirror of https://github.com/mamba-org/mamba.git
maint: Support `pybind11` 3 for `libmambapy`
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
This commit is contained in:
parent
4185322d51
commit
366738a35a
|
@ -47,7 +47,7 @@ dependencies:
|
|||
- scikit-build
|
||||
# libmambapy dependencies
|
||||
- python
|
||||
- pybind11<3.0.0
|
||||
- pybind11>=3.0.0
|
||||
# libmambapy-stubs build dependencies
|
||||
- mypy # For stubgen
|
||||
- setuptools
|
||||
|
|
|
@ -15,10 +15,9 @@
|
|||
namespace mambapy
|
||||
{
|
||||
template <typename Enum>
|
||||
auto enum_from_str(const pybind11::str& name)
|
||||
auto enum_from_str(const pybind11::str& name, pybind11::handle enum_class)
|
||||
{
|
||||
auto pyenum = pybind11::type::of<Enum>();
|
||||
return pyenum.attr("__members__")[name].template cast<Enum>();
|
||||
return enum_class.attr("__members__")[name].template cast<Enum>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -1484,21 +1484,26 @@ bind_submodule_impl(pybind11::module_ m)
|
|||
|
||||
////////////////////////////////////////////
|
||||
|
||||
py::enum_<QueryType>(m, "QueryType")
|
||||
.value("Search", QueryType::Search)
|
||||
.value("Depends", QueryType::Depends)
|
||||
.value("WhoNeeds", QueryType::WhoNeeds)
|
||||
.def(py::init(&mambapy::enum_from_str<QueryType>))
|
||||
.def_static("parse", &query_type_parse);
|
||||
auto query_type_enum = py::enum_<QueryType>(m, "QueryType")
|
||||
.value("Search", QueryType::Search)
|
||||
.value("Depends", QueryType::Depends)
|
||||
.value("WhoNeeds", QueryType::WhoNeeds)
|
||||
.def_static("parse", &query_type_parse);
|
||||
query_type_enum.def(py::init([&query_type_enum](const py::str& name)
|
||||
{ return mambapy::enum_from_str<QueryType>(name, query_type_enum); }
|
||||
));
|
||||
py::implicitly_convertible<py::str, QueryType>();
|
||||
|
||||
py::enum_<QueryResultFormat>(m, "QueryResultFormat")
|
||||
.value("Json", QueryResultFormat::Json)
|
||||
.value("Tree", QueryResultFormat::Tree)
|
||||
.value("Table", QueryResultFormat::Table)
|
||||
.value("Pretty", QueryResultFormat::Pretty)
|
||||
.value("RecursiveTable", QueryResultFormat::RecursiveTable)
|
||||
.def(py::init(&mambapy::enum_from_str<QueryResultFormat>));
|
||||
auto query_result_format_enum = py::enum_<QueryResultFormat>(m, "QueryResultFormat")
|
||||
.value("Json", QueryResultFormat::Json)
|
||||
.value("Tree", QueryResultFormat::Tree)
|
||||
.value("Table", QueryResultFormat::Table)
|
||||
.value("Pretty", QueryResultFormat::Pretty)
|
||||
.value("RecursiveTable", QueryResultFormat::RecursiveTable);
|
||||
query_result_format_enum.def(py::init(
|
||||
[&query_result_format_enum](const py::str& name)
|
||||
{ return mambapy::enum_from_str<QueryResultFormat>(name, query_result_format_enum); }
|
||||
));
|
||||
py::implicitly_convertible<py::str, QueryType>();
|
||||
|
||||
py::class_<QueryResult>(m, "QueryResult")
|
||||
|
|
|
@ -29,17 +29,23 @@ namespace mambapy
|
|||
using namespace mamba;
|
||||
using namespace mamba::solver::libsolv;
|
||||
|
||||
py::enum_<RepodataParser>(m, "RepodataParser")
|
||||
.value("Mamba", RepodataParser::Mamba)
|
||||
.value("Libsolv", RepodataParser::Libsolv)
|
||||
.def(py::init(&enum_from_str<RepodataParser>));
|
||||
auto repodata_parser_enum = py::enum_<RepodataParser>(m, "RepodataParser")
|
||||
.value("Mamba", RepodataParser::Mamba)
|
||||
.value("Libsolv", RepodataParser::Libsolv);
|
||||
repodata_parser_enum.def(
|
||||
py::init([&repodata_parser_enum](const py::str& name)
|
||||
{ return enum_from_str<RepodataParser>(name, repodata_parser_enum); })
|
||||
);
|
||||
py::implicitly_convertible<py::str, RepodataParser>();
|
||||
|
||||
py::enum_<MatchSpecParser>(m, "MatchSpecParser")
|
||||
.value("Mixed", MatchSpecParser::Mixed)
|
||||
.value("Mamba", MatchSpecParser::Mamba)
|
||||
.value("Libsolv", MatchSpecParser::Libsolv)
|
||||
.def(py::init(&enum_from_str<MatchSpecParser>));
|
||||
auto match_spec_parser_enum = py::enum_<MatchSpecParser>(m, "MatchSpecParser")
|
||||
.value("Mixed", MatchSpecParser::Mixed)
|
||||
.value("Mamba", MatchSpecParser::Mamba)
|
||||
.value("Libsolv", MatchSpecParser::Libsolv);
|
||||
match_spec_parser_enum.def(
|
||||
py::init([&match_spec_parser_enum](const py::str& name)
|
||||
{ return enum_from_str<MatchSpecParser>(name, match_spec_parser_enum); })
|
||||
);
|
||||
py::implicitly_convertible<py::str, MatchSpecParser>();
|
||||
|
||||
py::enum_<PipAsPythonDependency>(m, "PipAsPythonDependency")
|
||||
|
@ -48,12 +54,15 @@ namespace mambapy
|
|||
.def(py::init([](bool val) { return static_cast<PipAsPythonDependency>(val); }));
|
||||
py::implicitly_convertible<py::bool_, PipAsPythonDependency>();
|
||||
|
||||
py::enum_<PackageTypes>(m, "PackageTypes")
|
||||
.value("CondaOnly", PackageTypes::CondaOnly)
|
||||
.value("TarBz2Only", PackageTypes::TarBz2Only)
|
||||
.value("CondaAndTarBz2", PackageTypes::CondaAndTarBz2)
|
||||
.value("CondaOrElseTarBz2", PackageTypes::CondaOrElseTarBz2)
|
||||
.def(py::init(&enum_from_str<PackageTypes>));
|
||||
auto package_types_enum = py::enum_<PackageTypes>(m, "PackageTypes")
|
||||
.value("CondaOnly", PackageTypes::CondaOnly)
|
||||
.value("TarBz2Only", PackageTypes::TarBz2Only)
|
||||
.value("CondaAndTarBz2", PackageTypes::CondaAndTarBz2)
|
||||
.value("CondaOrElseTarBz2", PackageTypes::CondaOrElseTarBz2);
|
||||
package_types_enum.def(
|
||||
py::init([&package_types_enum](const py::str& name)
|
||||
{ return enum_from_str<PackageTypes>(name, package_types_enum); })
|
||||
);
|
||||
py::implicitly_convertible<py::str, PackageTypes>();
|
||||
|
||||
py::enum_<VerifyPackages>(m, "VerifyPackages")
|
||||
|
@ -62,12 +71,13 @@ namespace mambapy
|
|||
.def(py::init([](bool val) { return static_cast<VerifyPackages>(val); }));
|
||||
py::implicitly_convertible<py::bool_, VerifyPackages>();
|
||||
|
||||
py::enum_<LogLevel>(m, "LogLevel")
|
||||
.value("Debug", LogLevel::Debug)
|
||||
.value("Warning", LogLevel::Warning)
|
||||
.value("Error", LogLevel::Error)
|
||||
.value("Fatal", LogLevel::Fatal)
|
||||
.def(py::init(&enum_from_str<LogLevel>));
|
||||
auto log_level_enum = py::enum_<LogLevel>(m, "LogLevel")
|
||||
.value("Debug", LogLevel::Debug)
|
||||
.value("Warning", LogLevel::Warning)
|
||||
.value("Error", LogLevel::Error)
|
||||
.value("Fatal", LogLevel::Fatal);
|
||||
log_level_enum.def(py::init([&log_level_enum](const py::str& name)
|
||||
{ return enum_from_str<LogLevel>(name, log_level_enum); }));
|
||||
py::implicitly_convertible<py::bool_, LogLevel>();
|
||||
|
||||
py::class_<Priorities>(m, "Priorities")
|
||||
|
|
|
@ -63,46 +63,51 @@ namespace mambapy
|
|||
[](const mamba::fs::u8path& p) { return strip_archive_extension(p); }
|
||||
);
|
||||
|
||||
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);
|
||||
auto known_platform_enum = py::enum_<KnownPlatform>(m, "KnownPlatform")
|
||||
.value("noarch", KnownPlatform::noarch)
|
||||
.value("linux_32", KnownPlatform::linux_32)
|
||||
.value("linux_64", KnownPlatform::linux_64)
|
||||
.value("linux_aarch64", KnownPlatform::linux_aarch64)
|
||||
.value("linux_armv6l", KnownPlatform::linux_armv6l)
|
||||
.value("linux_armv7l", KnownPlatform::linux_armv7l)
|
||||
.value("linux_ppc64", KnownPlatform::linux_ppc64)
|
||||
.value("linux_ppc64le", KnownPlatform::linux_ppc64le)
|
||||
.value("linux_s390x", KnownPlatform::linux_s390x)
|
||||
.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_static("parse", &platform_parse)
|
||||
.def_static("count", &known_platforms_count)
|
||||
.def_static("build_platform", &build_platform);
|
||||
known_platform_enum.def(
|
||||
py::init([&known_platform_enum](const py::str& name)
|
||||
{ return enum_from_str<KnownPlatform>(name, known_platform_enum); })
|
||||
);
|
||||
py::implicitly_convertible<py::str, KnownPlatform>();
|
||||
|
||||
py::enum_<NoArchType>(m, "NoArchType")
|
||||
.value("No", NoArchType::No)
|
||||
.value("Generic", NoArchType::Generic)
|
||||
.value("Python", NoArchType::Python)
|
||||
.def(py::init(&enum_from_str<NoArchType>))
|
||||
.def_static("parse", &noarch_parse)
|
||||
.def_static("count", &known_noarch_count);
|
||||
auto noarch_type_enum = py::enum_<NoArchType>(m, "NoArchType")
|
||||
.value("No", NoArchType::No)
|
||||
.value("Generic", NoArchType::Generic)
|
||||
.value("Python", NoArchType::Python)
|
||||
.def_static("parse", &noarch_parse)
|
||||
.def_static("count", &known_noarch_count);
|
||||
noarch_type_enum.def(py::init([&noarch_type_enum](const py::str& name)
|
||||
{ return enum_from_str<NoArchType>(name, noarch_type_enum); }));
|
||||
py::implicitly_convertible<py::str, NoArchType>();
|
||||
|
||||
auto py_conda_url = py::class_<CondaURL>(m, "CondaURL");
|
||||
|
||||
py::enum_<CondaURL::Credentials>(py_conda_url, "Credentials")
|
||||
.value("Hide", CondaURL::Credentials::Hide)
|
||||
.value("Show", CondaURL::Credentials::Show)
|
||||
.value("Remove", CondaURL::Credentials::Remove)
|
||||
.def(py::init(&enum_from_str<CondaURL::Credentials>));
|
||||
auto conda_url_credentials_enum = py::enum_<CondaURL::Credentials>(py_conda_url, "Credentials")
|
||||
.value("Hide", CondaURL::Credentials::Hide)
|
||||
.value("Show", CondaURL::Credentials::Show)
|
||||
.value("Remove", CondaURL::Credentials::Remove);
|
||||
conda_url_credentials_enum.def(py::init(
|
||||
[&conda_url_credentials_enum](const py::str& name)
|
||||
{ return enum_from_str<CondaURL::Credentials>(name, conda_url_credentials_enum); }
|
||||
));
|
||||
py::implicitly_convertible<py::str, CondaURL::Credentials>();
|
||||
|
||||
py_conda_url //
|
||||
|
@ -315,14 +320,20 @@ namespace mambapy
|
|||
|
||||
auto py_unresolved_channel = py::class_<UnresolvedChannel>(m, "UnresolvedChannel");
|
||||
|
||||
py::enum_<UnresolvedChannel::Type>(py_unresolved_channel, "Type")
|
||||
.value("URL", UnresolvedChannel::Type::URL)
|
||||
.value("PackageURL", UnresolvedChannel::Type::PackageURL)
|
||||
.value("Path", UnresolvedChannel::Type::Path)
|
||||
.value("PackagePath", UnresolvedChannel::Type::PackagePath)
|
||||
.value("Name", UnresolvedChannel::Type::Name)
|
||||
.value("Unknown", UnresolvedChannel::Type::Unknown)
|
||||
.def(py::init(&enum_from_str<UnresolvedChannel::Type>));
|
||||
auto unresolved_channel_type_enum = py::enum_<UnresolvedChannel::Type>(
|
||||
py_unresolved_channel,
|
||||
"Type"
|
||||
)
|
||||
.value("URL", UnresolvedChannel::Type::URL)
|
||||
.value("PackageURL", UnresolvedChannel::Type::PackageURL)
|
||||
.value("Path", UnresolvedChannel::Type::Path)
|
||||
.value("PackagePath", UnresolvedChannel::Type::PackagePath)
|
||||
.value("Name", UnresolvedChannel::Type::Name)
|
||||
.value("Unknown", UnresolvedChannel::Type::Unknown);
|
||||
unresolved_channel_type_enum.def(py::init(
|
||||
[&unresolved_channel_type_enum](const py::str& name)
|
||||
{ return enum_from_str<UnresolvedChannel::Type>(name, unresolved_channel_type_enum); }
|
||||
));
|
||||
py::implicitly_convertible<py::str, UnresolvedChannel::Type>();
|
||||
|
||||
py_unresolved_channel //
|
||||
|
@ -436,11 +447,14 @@ namespace mambapy
|
|||
.def("__copy__", ©<BasicHTTPAuthentication>)
|
||||
.def("__deepcopy__", &deepcopy<BasicHTTPAuthentication>, py::arg("memo"));
|
||||
|
||||
py::enum_<Channel::Match>(py_channel, "Match")
|
||||
.value("No", Channel::Match::No)
|
||||
.value("InOtherPlatform", Channel::Match::InOtherPlatform)
|
||||
.value("Full", Channel::Match::Full)
|
||||
.def(py::init(&enum_from_str<Channel::Match>));
|
||||
auto channel_match_enum = py::enum_<Channel::Match>(py_channel, "Match")
|
||||
.value("No", Channel::Match::No)
|
||||
.value("InOtherPlatform", Channel::Match::InOtherPlatform)
|
||||
.value("Full", Channel::Match::Full);
|
||||
channel_match_enum.def(
|
||||
py::init([&channel_match_enum](const py::str& name)
|
||||
{ return enum_from_str<Channel::Match>(name, channel_match_enum); })
|
||||
);
|
||||
py::implicitly_convertible<py::str, Channel::Match>();
|
||||
|
||||
py_channel //
|
||||
|
|
|
@ -57,36 +57,42 @@ namespace mambapy
|
|||
{
|
||||
namespace py = pybind11;
|
||||
|
||||
py::enum_<fmt::emphasis>(m, "TextEmphasis")
|
||||
.value("Bold", fmt::emphasis::bold)
|
||||
.value("Faint", fmt::emphasis::faint)
|
||||
.value("Italic", fmt::emphasis::italic)
|
||||
.value("Underline", fmt::emphasis::underline)
|
||||
.value("Blink", fmt::emphasis::blink)
|
||||
.value("Reverse", fmt::emphasis::reverse)
|
||||
.value("Conceal", fmt::emphasis::conceal)
|
||||
.value("Strikethrough", fmt::emphasis::strikethrough)
|
||||
.def(py::init(&enum_from_str<fmt::emphasis>));
|
||||
auto text_emphasis_enum = py::enum_<fmt::emphasis>(m, "TextEmphasis")
|
||||
.value("Bold", fmt::emphasis::bold)
|
||||
.value("Faint", fmt::emphasis::faint)
|
||||
.value("Italic", fmt::emphasis::italic)
|
||||
.value("Underline", fmt::emphasis::underline)
|
||||
.value("Blink", fmt::emphasis::blink)
|
||||
.value("Reverse", fmt::emphasis::reverse)
|
||||
.value("Conceal", fmt::emphasis::conceal)
|
||||
.value("Strikethrough", fmt::emphasis::strikethrough);
|
||||
text_emphasis_enum.def(
|
||||
py::init([&text_emphasis_enum](const py::str& name)
|
||||
{ return enum_from_str<fmt::emphasis>(name, text_emphasis_enum); })
|
||||
);
|
||||
py::implicitly_convertible<py::str, fmt::emphasis>();
|
||||
|
||||
py::enum_<fmt::terminal_color>(m, "TextTerminalColor")
|
||||
.value("Black", fmt::terminal_color::black)
|
||||
.value("Red", fmt::terminal_color::red)
|
||||
.value("Green", fmt::terminal_color::green)
|
||||
.value("Yellow", fmt::terminal_color::yellow)
|
||||
.value("Blue", fmt::terminal_color::blue)
|
||||
.value("Magenta", fmt::terminal_color::magenta)
|
||||
.value("Cyan", fmt::terminal_color::cyan)
|
||||
.value("White", fmt::terminal_color::white)
|
||||
.value("BrightBlack", fmt::terminal_color::bright_black)
|
||||
.value("BrightRed", fmt::terminal_color::bright_red)
|
||||
.value("BrightGreen", fmt::terminal_color::bright_green)
|
||||
.value("BrightYellow", fmt::terminal_color::bright_yellow)
|
||||
.value("BrightBlue", fmt::terminal_color::bright_blue)
|
||||
.value("BrightMagenta", fmt::terminal_color::bright_magenta)
|
||||
.value("BrightCyan", fmt::terminal_color::bright_cyan)
|
||||
.value("BrightWhite", fmt::terminal_color::bright_white)
|
||||
.def(py::init(&enum_from_str<fmt::terminal_color>));
|
||||
auto text_terminal_color_enum = py::enum_<fmt::terminal_color>(m, "TextTerminalColor")
|
||||
.value("Black", fmt::terminal_color::black)
|
||||
.value("Red", fmt::terminal_color::red)
|
||||
.value("Green", fmt::terminal_color::green)
|
||||
.value("Yellow", fmt::terminal_color::yellow)
|
||||
.value("Blue", fmt::terminal_color::blue)
|
||||
.value("Magenta", fmt::terminal_color::magenta)
|
||||
.value("Cyan", fmt::terminal_color::cyan)
|
||||
.value("White", fmt::terminal_color::white)
|
||||
.value("BrightBlack", fmt::terminal_color::bright_black)
|
||||
.value("BrightRed", fmt::terminal_color::bright_red)
|
||||
.value("BrightGreen", fmt::terminal_color::bright_green)
|
||||
.value("BrightYellow", fmt::terminal_color::bright_yellow)
|
||||
.value("BrightBlue", fmt::terminal_color::bright_blue)
|
||||
.value("BrightMagenta", fmt::terminal_color::bright_magenta)
|
||||
.value("BrightCyan", fmt::terminal_color::bright_cyan)
|
||||
.value("BrightWhite", fmt::terminal_color::bright_white);
|
||||
text_terminal_color_enum.def(
|
||||
py::init([&text_terminal_color_enum](const py::str& name)
|
||||
{ return enum_from_str<fmt::terminal_color>(name, text_terminal_color_enum); })
|
||||
);
|
||||
py::implicitly_convertible<py::str, fmt::terminal_color>();
|
||||
|
||||
py::class_<fmt::rgb>(m, "TextRGBColor")
|
||||
|
|
Loading…
Reference in New Issue