MCPcopy Create free account
hub / github.com/MITK/MITK / BeginVirtualEnvPhase

Method BeginVirtualEnvPhase

Modules/PythonInstaller/src/QmitkPipInstaller.cpp:401–439  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

399// the venv is unnecessary or already exists, activates it and dispatches
400// synchronously to the next phase.
401void 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
441void QmitkPipInstaller::StartPipUpgrade()
442{

Callers 1

StartInstallMethod · 0.95

Calls 7

StartPipUpgradeMethod · 0.95
StartResolveGroupMethod · 0.95
ActivateVirtualEnvFunction · 0.85
FormatCommandFunction · 0.85
emptyMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected