diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/pybindings.cc | 14 | ||||
-rw-r--r-- | common/pybindings.h | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/common/pybindings.cc b/common/pybindings.cc index 13e0976c..02c39fa3 100644 --- a/common/pybindings.cc +++ b/common/pybindings.cc @@ -127,11 +127,9 @@ BOOST_PYTHON_MODULE(MODULE_NAME) class_<Context, Context *, bases<Arch>, boost::noncopyable>("Context", no_init).def("checksum", &Context::checksum); } -void arch_appendinittab() { PyImport_AppendInittab(TOSTRING(MODULE_NAME), PYINIT_MODULE_NAME); } - static wchar_t *program; -void init_python(const char *executable) +void init_python(const char *executable,bool first) { #ifdef MAIN_EXECUTABLE program = Py_DecodeLocale(executable, NULL); @@ -140,11 +138,15 @@ void init_python(const char *executable) exit(1); } try { - PyImport_AppendInittab(TOSTRING(MODULE_NAME), PYINIT_MODULE_NAME); - emb::append_inittab(); + if (first) + { + PyImport_AppendInittab(TOSTRING(MODULE_NAME), PYINIT_MODULE_NAME); + emb::append_inittab(); + } Py_SetProgramName(program); Py_Initialize(); - PyImport_ImportModule(TOSTRING(MODULE_NAME)); + if (first) + PyImport_ImportModule(TOSTRING(MODULE_NAME)); } catch (boost::python::error_already_set const &) { // Parse and output the exception std::string perror_str = parse_python_exception(); diff --git a/common/pybindings.h b/common/pybindings.h index 1f5ca004..4180c2e9 100644 --- a/common/pybindings.h +++ b/common/pybindings.h @@ -100,14 +100,12 @@ template <typename Tn> void python_export_global(const char *name, Tn &x) } }; -void init_python(const char *executable); +void init_python(const char *executable, bool first); void deinit_python(); void execute_python_file(const char *python_file); -void arch_appendinittab(); - NEXTPNR_NAMESPACE_END #endif /* end of include guard: COMMON_PYBINDINGS_HH */ |