python: Replace PYBIND11_EMBEDDED_MODULE with GEM5_PYBIND_MODULE_INIT.

That will make it possible for gem5's static intializers to run even if
the python interpreter has started.

Change-Id: Ic3574c32244e5ac475222f6d305ddc70dd6298d6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/54004
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/54264
This commit is contained in:
Gabe Black
2021-12-11 05:51:11 -08:00
committed by Bobby Bruce
parent 4f987ff52d
commit ebbfe1d281
2 changed files with 14 additions and 7 deletions

View File

@@ -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