libcalamares: repair submodule utils

This commit is contained in:
Adriaan de Groot 2023-10-21 16:34:07 +02:00
parent 945180e1d3
commit b2337c82a7

View File

@ -566,10 +566,14 @@ GlobalStorageProxy::value( const std::string& key ) const
} // namespace Python
} // namespace Calamares
PYBIND11_EMBEDDED_MODULE( utils, m )
// Not using EMBEDDED_MODULE because that does not let
// use use name "libcalamares.utils" and using just "utils"
// causes command-line use of Python3 followed by `import libcalamares`
// to crash with an error about adding modules after the interpreter
// has been initialized.
static void
populate_utils( py::module_&& m )
{
m.doc() = "Calamares Utility API for Python";
m.def( "obscure", &Calamares::Python::obscure, "A function that obscures (encodes) a string" );
m.def( "debug", &Calamares::Python::debug, "Log a debug-message" );
@ -628,7 +632,7 @@ PYBIND11_MODULE( libcalamares, m )
m.add_object( "VERSION", Calamares::Python::String( CALAMARES_VERSION ) );
m.add_object( "VERSION_SHORT", Calamares::Python::String( CALAMARES_VERSION_SHORT ) );
m.add_object( "utils", py::module::import( "utils" ) );
populate_utils( m.def_submodule( "utils", "Calamares Utility API for Python" ) );
py::class_< Calamares::Python::JobProxy >( m, "Job" )
.def_readonly( "module_name", &Calamares::Python::JobProxy::moduleName )