53#if PY_VERSION_HEX < 0x03080000
56 std::unique_ptr<
wchar_t[],
decltype(&PyMem_RawFree)> program(
57 Py_DecodeLocale(argv[0],
nullptr),
62 Py_SetProgramName(program.get());
69 PyConfig_InitPythonConfig(&config);
72 status = PyConfig_SetBytesString(&config, &config.program_name,
74 if (PyStatus_Exception(
status)) {
75 PyConfig_Clear(&config);
76 Py_ExitStatusException(
status);
81 py::scoped_interpreter guard(
true, argc, argv);
83 auto importer = py::module_::import(
"importer");
84 importer.attr(
"install")();
87 py::module_::import(
"m5").attr(
"main")();
88 }
catch (py::error_already_set &
e) {
89 if (
e.matches(PyExc_SystemExit))
90 return e.value().attr(
"code").cast<
int>();
92 std::cerr <<
e.what();