diff --git a/src/python/importer.cc b/src/python/importer.cc index 2d10e962b4..dde86a8896 100644 --- a/src/python/importer.cc +++ b/src/python/importer.cc @@ -25,15 +25,20 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "pybind11/embed.h" +#include "pybind11/eval.h" #include "pybind11/pybind11.h" -#include "python/m5ImporterCode.hh" #include "python/embedded.hh" +#include "python/m5ImporterCode.hh" +#include "python/pybind_init.hh" namespace py = pybind11; -PYBIND11_EMBEDDED_MODULE(importer, m) +namespace +{ + +void +importerInit(py::module_ &m) { m.def("_init_all_embedded", gem5::EmbeddedPython::initAll); py::str importer_code( @@ -41,3 +46,7 @@ PYBIND11_EMBEDDED_MODULE(importer, m) gem5::Blobs::m5ImporterCode_len); py::exec(std::move(importer_code), m.attr("__dict__")); } + +GEM5_PYBIND_MODULE_INIT(importer, importerInit) + +} // anonymous namespace diff --git a/src/sim/init.cc b/src/sim/init.cc index 8c0d1aa271..d594b08933 100644 --- a/src/sim/init.cc +++ b/src/sim/init.cc @@ -48,6 +48,7 @@ #include "base/cprintf.hh" #include "python/pybind11/pybind.hh" +#include "python/pybind_init.hh" namespace py = pybind11; @@ -126,9 +127,6 @@ EmbeddedPyBind::initAll(py::module_ &_m5) } } -PYBIND11_EMBEDDED_MODULE(_m5, _m5) -{ - EmbeddedPyBind::initAll(_m5); -} +GEM5_PYBIND_MODULE_INIT(_m5, EmbeddedPyBind::initAll) } // namespace gem5