MCPcopy Create free account
hub / github.com/Kitware/VTK / vtkPythonPreConfig

Function vtkPythonPreConfig

Utilities/PythonInterpreter/vtkPythonInterpreter.cxx:241–269  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Ensure that Python is pre-initialized enough for VTK to do its initialization. Must be called before any `PyMem_*` calls are made.

Source from the content-addressed store, hash-verified

239// Ensure that Python is pre-initialized enough for VTK to do its
240// initialization. Must be called before any `PyMem_*` calls are made.
241static bool vtkPythonPreConfig()
242{
243 // Guard against doing this multiple times.
244 static bool done = false;
245 if (done)
246 {
247 return false;
248 }
249 done = true;
250
251#if PY_VERSION_HEX >= 0x03080000
252 PyStatus status;
253 PyPreConfig preconfig;
254 PyPreConfig_InitPythonConfig(&preconfig);
255
256 preconfig.allocator = PYMEM_ALLOCATOR_NOT_SET;
257 preconfig.utf8_mode = 1;
258
259 status = Py_PreInitialize(&preconfig);
260 if (PyStatus_Exception(status))
261 {
262 Py_ExitStatusException(status);
263 }
264
265 return preconfig.isolated;
266#else
267 return Py_FrozenFlag;
268#endif
269}
270
271//------------------------------------------------------------------------------
272namespace

Callers 2

InitializeWithArgsMethod · 0.85
SetProgramNameMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected