| 25 | namespace |
| 26 | { |
| 27 | void ActivateVirtualEnv(const std::string& venvName) |
| 28 | { |
| 29 | if (!mitk::PythonHelper::VirtualEnvExists(venvName)) |
| 30 | { |
| 31 | MITK_INFO << "Create virtual environment: " << venvName; |
| 32 | const auto venvPath = mitk::PythonHelper::CreateVirtualEnv(venvName); |
| 33 | |
| 34 | if (venvPath.empty()) |
| 35 | mitkThrow() << "Could not create virtual environment: " |
| 36 | << mitk::PythonHelper::GetVirtualEnvPath(venvName); |
| 37 | } |
| 38 | |
| 39 | if (!mitk::PythonHelper::ActivateVirtualEnv(venvName)) |
| 40 | mitkThrow() << "Could not activate virtual environment: " << venvName; |
| 41 | |
| 42 | MITK_INFO << "Using virtual environment: " << venvName; |
| 43 | } |
| 44 | |
| 45 | // Inserts a key into a dict on construction and removes it on |
| 46 | // destruction. GIL must be held by the caller for both. Used to scope |
no test coverage detected