Either kicks off a `python -m venv ` subprocess (asynchronous) or, if the venv is unnecessary or already exists, activates it and dispatches synchronously to the next phase.
| 399 | // the venv is unnecessary or already exists, activates it and dispatches |
| 400 | // synchronously to the next phase. |
| 401 | void QmitkPipInstaller::BeginVirtualEnvPhase() |
| 402 | { |
| 403 | if (m_Spec.venvName.empty() || mitk::PythonHelper::VirtualEnvExists(m_Spec.venvName)) |
| 404 | { |
| 405 | // No venv needed or already exists - just activate and move on. |
| 406 | if (!m_Spec.venvName.empty() && !mitk::PythonHelper::ActivateVirtualEnv(m_Spec.venvName)) |
| 407 | { |
| 408 | m_State = State::Failed; |
| 409 | emit ErrorOccurred("Failed to activate virtual environment."); |
| 410 | emit InstallFinished(false); |
| 411 | return; |
| 412 | } |
| 413 | |
| 414 | if (m_Spec.upgradePipFirst) |
| 415 | { |
| 416 | this->StartPipUpgrade(); |
| 417 | } |
| 418 | else |
| 419 | { |
| 420 | emit ResolveStarted(); |
| 421 | this->StartResolveGroup(); |
| 422 | } |
| 423 | return; |
| 424 | } |
| 425 | |
| 426 | const auto python = this->RequirePythonExecutable(); |
| 427 | |
| 428 | if (python.isEmpty()) |
| 429 | return; |
| 430 | |
| 431 | m_State = State::CreatingVirtualEnv; |
| 432 | m_CreatedVirtualEnv = true; |
| 433 | emit VirtualEnvCreationStarted(); |
| 434 | |
| 435 | const auto venvPath = mitk::PythonHelper::GetVirtualEnvPath(m_Spec.venvName); |
| 436 | QStringList args = { "-m", "venv", QString::fromStdString(venvPath.string()) }; |
| 437 | MITK_INFO << FormatCommand(python, args).toStdString(); |
| 438 | m_Process->start(python, args); |
| 439 | } |
| 440 | |
| 441 | void QmitkPipInstaller::StartPipUpgrade() |
| 442 | { |
no test coverage detected