static
| 161 | |
| 162 | //static |
| 163 | void ScriptModule::InitializePythonIfNecessary() |
| 164 | { |
| 165 | if (!sPythonInitialized) |
| 166 | { |
| 167 | #ifdef BESPOKE_PORTABLE_PYTHON |
| 168 | static const auto pythonHomeUtf8{ ofToFactoryPath("python") }; |
| 169 | static auto PYTHONHOME{ toPythonHome(pythonHomeUtf8, Py_SetPythonHome) }; |
| 170 | Py_SetPythonHome(PYTHONHOME.data()); |
| 171 | #endif |
| 172 | py::initialize_interpreter(); |
| 173 | #ifdef BESPOKE_PORTABLE_PYTHON |
| 174 | py::exec(std::string{ "import sys; sys.executable = '" } + pythonHomeUtf8 + "/" BESPOKE_PORTABLE_PYTHON "'; del sys"); |
| 175 | #endif |
| 176 | py::exec(GetBootstrapImportString(), py::globals()); |
| 177 | |
| 178 | CodeEntry::OnPythonInit(); |
| 179 | } |
| 180 | sPythonInitialized = true; |
| 181 | |
| 182 | if (!sHasPythonEverSuccessfullyInitialized) |
| 183 | { |
| 184 | File(ofToDataPath("internal/python_" + std::string(Bespoke::PYTHON_VERSION) + "_installed")).create(); |
| 185 | sHasPythonEverSuccessfullyInitialized = true; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | //static |
| 190 | void ScriptModule::CheckIfPythonEverSuccessfullyInitialized() |
nothing calls this directly
no test coverage detected