------------------------------------------------------------------------------ Ensure that Python is pre-initialized enough for VTK to do its initialization. Must be called before any `PyMem_*` calls are made.
| 239 | // Ensure that Python is pre-initialized enough for VTK to do its |
| 240 | // initialization. Must be called before any `PyMem_*` calls are made. |
| 241 | static 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 | //------------------------------------------------------------------------------ |
| 272 | namespace |
no outgoing calls
no test coverage detected