52main(
int argc,
const char **argv)
54#if PY_VERSION_HEX >= 0x03080000
58 PyPreConfig preconfig;
59 PyPreConfig_InitPythonConfig(&preconfig);
61 preconfig.utf8_mode = 1;
63 status = Py_PreInitialize(&preconfig);
64 if (PyStatus_Exception(status)) {
65 Py_ExitStatusException(status);
69 py::scoped_interpreter guard;
73 auto sys = py::module::import(
"sys");
74 if (py::hasattr(sys,
"argv")) {
76 py_argv = sys.attr(
"argv");
79 sys.add_object(
"argv", py_argv);
82 py_argv.attr(
"clear")();
85 std::cerr <<
"Usage: gem5py SCRIPT [arg] ..." << std::endl;
90 for (
int i = 1; i < argc; i++)
91 py_argv.append(argv[i]);
94 py::eval_file(argv[1]);