diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2018-06-27 11:45:19 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2018-06-27 11:45:19 +0200 |
commit | bafb4702c7176a08e4a9b2088297071a7bed6656 (patch) | |
tree | a59132f64cba845f2b65c02441229fa26a00aa9e /common | |
parent | 9bb489936078980e98fc873845b2ca64ddb490fb (diff) | |
download | nextpnr-bafb4702c7176a08e4a9b2088297071a7bed6656.tar.gz nextpnr-bafb4702c7176a08e4a9b2088297071a7bed6656.tar.bz2 nextpnr-bafb4702c7176a08e4a9b2088297071a7bed6656.zip |
reinit python tab
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 */ |