Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkPipInstaller Class Reference

Headless pip installer with structured progress reporting. More...

#include <QmitkPipInstaller.h>

Inheritance diagram for QmitkPipInstaller:
Collaboration diagram for QmitkPipInstaller:

Signals

void VirtualEnvCreationStarted ()
 Emitted when virtual environment creation starts. More...
 
void PipUpgradeStarted ()
 Emitted when the pip upgrade step starts. More...
 
void ResolveStarted ()
 Emitted when resolution of a group starts. More...
 
void PackageStatusChanged (int index, const QString &name, mitk::PackageStatus status)
 Emitted when a package's installation status changes. More...
 
void PostInstallStepStarted (const QString &displayName)
 Emitted when a post-install step starts. More...
 
void InstallFinished (bool success)
 Emitted when the installation terminates. More...
 
void OutputReceived (const QString &text, bool isError)
 Raw process output for display in a details view. More...
 
void ProgressChanged (int current, int total)
 Per-package progress during the install phase only. More...
 
void ErrorOccurred (const QString &message)
 Emitted on fatal errors (e.g. Python executable not found). More...
 

Public Member Functions

 QmitkPipInstaller (QObject *parent=nullptr)
 
 ~QmitkPipInstaller () override
 
void SetInstallSpec (const mitk::PipInstallSpec &spec)
 Set the installation specification. More...
 
void StartInstall ()
 Start the installation. More...
 
void Cancel ()
 Cancel the current operation. More...
 
void AbandonInstall ()
 Tear down anything this installer created during a failed install. More...
 
bool IsRunning () const
 Whether an operation is currently running. More...
 
const std::vector< mitk::PipPackageInfo > & GetResolvedPackages () const
 The full list of resolved packages across all groups. More...
 

Detailed Description

Headless pip installer with structured progress reporting.

Manages pip package installation as a two-phase process per install group:

  1. Resolve: runs pip install –dry-run –report to determine the full set of packages that would be installed.
  2. Install: installs resolved packages one-by-one with –no-deps for per-package status tracking.

Install groups (PipInstallGroup) are processed sequentially. Each group can have its own index URL and pip arguments. This supports scenarios like installing PyTorch from a CUDA-specific index while installing other packages from the default PyPI.

All operations are asynchronous. Progress is communicated through Qt signals.

Note
This class is not thread-safe. Construct, use, and destroy from a single thread (typically the GUI thread). All Qt signal connections use direct dispatch unless the consumer explicitly requests queued connections.
See also
mitk::PipInstallSpec, mitk::PipInstallGroup, mitk::PipPackageInfo, QmitkPipInstallDialog

Definition at line 43 of file QmitkPipInstaller.h.

Constructor & Destructor Documentation

◆ QmitkPipInstaller()

QmitkPipInstaller::QmitkPipInstaller ( QObject *  parent = nullptr)
explicit

◆ ~QmitkPipInstaller()

QmitkPipInstaller::~QmitkPipInstaller ( )
override

Member Function Documentation

◆ AbandonInstall()

void QmitkPipInstaller::AbandonInstall ( )

Tear down anything this installer created during a failed install.

Intended to be called by the consumer when it gives up after a failed install (e.g. the user dismisses the install dialog instead of retrying). If a venv was created by this installer and the last operation ended in the Failed state, the venv is removed.

Has no effect after a successful install (Done state) or while an operation is still running - in the latter case call Cancel() instead.

◆ Cancel()

void QmitkPipInstaller::Cancel ( )

Cancel the current operation.

Kills the running pip process and returns immediately. The terminal InstallFinished(false) signal is deferred until the killed process reports finished, at which point venv removal (if one was created) runs synchronously on the calling thread inside the finished slot. For a GUI consumer this means the event loop is briefly blocked by fs::remove_all; in practice this is fast but can stall on a slow disk or if an antivirus scanner holds a handle open.

◆ ErrorOccurred

void QmitkPipInstaller::ErrorOccurred ( const QString &  message)
signal

Emitted on fatal errors (e.g. Python executable not found).

◆ GetResolvedPackages()

const std::vector<mitk::PipPackageInfo>& QmitkPipInstaller::GetResolvedPackages ( ) const

The full list of resolved packages across all groups.

Grows as each group resolves: after ParseResolveReport emits the per-package Pending entries via PackageStatusChanged, those entries are present in this list. Fully populated before InstallFinished.

◆ InstallFinished

void QmitkPipInstaller::InstallFinished ( bool  success)
signal

Emitted when the installation terminates.

Fires exactly once per StartInstall() call, covering both success and every failure mode (resolve failure, package install failure, a non-optional post-install step failure, setup errors).

Setup and failure messages arrive via ErrorOccurred before this signal; consumers that want to display a specific cause should use that signal (or accumulated OutputReceived) rather than relying on a per-phase Finished signal.

Parameters
[in]successTrue only if every package installed successfully and every non-optional model download succeeded.

◆ IsRunning()

bool QmitkPipInstaller::IsRunning ( ) const

Whether an operation is currently running.

◆ OutputReceived

void QmitkPipInstaller::OutputReceived ( const QString &  text,
bool  isError 
)
signal

Raw process output for display in a details view.

Parameters
[in]textThe output text.
[in]isErrorTrue if the text came from stderr.

◆ PackageStatusChanged

void QmitkPipInstaller::PackageStatusChanged ( int  index,
const QString &  name,
mitk::PackageStatus  status 
)
signal

Emitted when a package's installation status changes.

During resolve, fires once per resolved package with status Pending. During install, fires with status Installing, Installed, or Failed.

Parameters
[in]indexIndex into the resolved packages list.
[in]nameThe package name.
[in]statusThe new status.

◆ PipUpgradeStarted

void QmitkPipInstaller::PipUpgradeStarted ( )
signal

Emitted when the pip upgrade step starts.

◆ PostInstallStepStarted

void QmitkPipInstaller::PostInstallStepStarted ( const QString &  displayName)
signal

Emitted when a post-install step starts.

Fired once per entry in PipInstallSpec::postInstallSteps, in order.

Parameters
[in]displayNameThe step's display name.

◆ ProgressChanged

void QmitkPipInstaller::ProgressChanged ( int  current,
int  total 
)
signal

Per-package progress during the install phase only.

Fires during the Installing state for each resolved package as the installer advances through the combined resolved list. Not emitted during virtual-env creation, pip upgrade, resolve, or model download - those phases are treated as indeterminate by the dialog.

Parameters
[in]currentNumber of packages finished so far in the install phase.
[in]totalTotal number of resolved packages across all groups.

◆ ResolveStarted

void QmitkPipInstaller::ResolveStarted ( )
signal

Emitted when resolution of a group starts.

◆ SetInstallSpec()

void QmitkPipInstaller::SetInstallSpec ( const mitk::PipInstallSpec &  spec)

Set the installation specification.

Must be called before StartInstall(). Has no effect (and logs a warning) while an operation is running.

◆ StartInstall()

void QmitkPipInstaller::StartInstall ( )

Start the installation.

For each install group in PipInstallSpec::groups, the engine first runs a pip install –dry-run –report to determine the full set of packages, then installs them one-by-one with –no-deps. Groups are processed sequentially so that the next group's resolve sees the previous group's packages already installed (essential for cases like a CUDA-specific PyTorch index).

Has no effect if an operation is already running.

◆ VirtualEnvCreationStarted

void QmitkPipInstaller::VirtualEnvCreationStarted ( )
signal

Emitted when virtual environment creation starts.


The documentation for this class was generated from the following file: