Call this to initialize the Python environment. */
| 809 | /** Call this to initialize the Python environment. |
| 810 | */ |
| 811 | bool GDALPythonInitialize() |
| 812 | { |
| 813 | std::lock_guard<std::mutex> guard(gMutexGDALPython); |
| 814 | |
| 815 | if (!LoadPythonAPI()) |
| 816 | return false; |
| 817 | |
| 818 | int bIsInitialized = Py_IsInitialized(); |
| 819 | if (!bIsInitialized) |
| 820 | { |
| 821 | gbHasInitializedPython = true; |
| 822 | CPLDebug("GDAL", "Before Py_Initialize()"); |
| 823 | Py_InitializeEx(0); |
| 824 | CPLDebug("GDAL", "Py_Initialize()"); |
| 825 | PyEval_InitThreads(); |
| 826 | gphThreadState = PyEval_SaveThread(); |
| 827 | } |
| 828 | |
| 829 | return true; |
| 830 | } |
| 831 | |
| 832 | /************************************************************************/ |
| 833 | /* GDALPythonFinalize() */ |
no test coverage detected