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:
@@ -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__ )
|
||||
|
||||
Reference in New Issue
Block a user