28#ifndef __PYTHON_PYBIND_INIT_HH__
29#define __PYTHON_PYBIND_INIT_HH__
33#include "pybind11/pybind11.h"
42 if (Py_IsInitialized()) {
44 PyImport_AddModule(
name);
45 PyObject *sys_modules = PyImport_GetModuleDict();
46 PyDict_SetItemString(sys_modules,
name, func());
49 PyImport_AppendInittab(
name, func);
56#define GEM5_PYBIND_MODULE_INIT(name, func) \
62 static ::pybind11::module_::module_def mod_def; \
63 static auto m = ::pybind11::module_::create_extension_module( \
64 #name, nullptr, &mod_def); \
70::gem5::PybindModuleInit modInit(#name, initializer); \
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
PybindModuleInit(const char *name, PyObject *(*func)())
const std::string & name()