SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Macros
PythonAutoInit.h File Reference
#include "smtk/common/CompilerInformation.h"
#include "pybind11/pybind11.h"
#include "smtk/common/PythonInterpreter.h"
#include <iostream>
Include dependency graph for PythonAutoInit.h:

Go to the source code of this file.

Macros

#define smtkPythonInitMacro(C, ModuleName, WarnOnFailure)
 

Macro Definition Documentation

◆ smtkPythonInitMacro

#define smtkPythonInitMacro (   C,
  ModuleName,
  WarnOnFailure 
)
Value:
static struct C##_PythonComponentInit \
{ \
/* Call <mod>_AutoInit_Construct during initialization. */ \
C##_PythonComponentInit() \
{ \
smtk::common::PythonInterpreter::instance().initialize(); \
if (!smtk::common::PythonInterpreter::instance().canFindModule(#ModuleName)) \
{ \
if (WarnOnFailure) \
{ \
std::cerr << "WARNING: \"" << #ModuleName \
<< "\" has been requested but cannot be imported." << std::endl; \
std::cerr << std::endl << "Paths searched:" << std::endl; \
auto paths = smtk::common::PythonInterpreter::instance().pythonPath(); \
for (auto path : paths) \
{ \
std::cerr << path << std::endl; \
} \
} \
} \
else \
{ \
pybind11::module mod = pybind11::module::import(#ModuleName); \
} \
} \
/* Call <mod>_AutoInit_Destruct during finalization. */ \
~C##_PythonComponentInit() {} \
} C##_PythonComponentInit_Instance;