Use Python to test for modules (not CPython)

CPython call requires Python 3.8+, so we work around to keep the 3.6
users happy

Fixes https://gitlab.com/kicad/code/kicad/issues/8554
This commit is contained in:
Seth Hillbrand
2021-06-07 13:55:28 -07:00
parent d4edc70f65
commit 891e200fc8
3 changed files with 22 additions and 9 deletions
+17
View File
@@ -98,6 +98,23 @@ bool SCRIPTING::IsWxAvailable()
#endif
}
bool SCRIPTING::IsModuleLoaded( std::string& aModule )
{
PyLOCK lock;
using namespace pybind11::literals;
auto locals = pybind11::dict( "modulename"_a = aModule );
pybind11::exec( R"(
import sys
loaded = False
if modulename in sys.modules:
loaded = True
)", pybind11::globals(), locals );
return locals["loaded"].cast<bool>();
}
bool SCRIPTING::scriptingSetup()
{
#if defined( __WINDOWS__ )