v2.0.0
Loading...
Searching...
No Matches
python_runner.h File Reference

Embedding-free launcher that runs MNE-Python (or any user) scripts as a child process and streams their output back to the C++ caller. More...

#include "utils_global.h"
#include <QObject>
#include <QString>
#include <QStringList>
#include <QProcessEnvironment>
#include <functional>
Include dependency graph for python_runner.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  UTILSLIB::PythonRunnerResult
 Script execution result container. More...
struct  UTILSLIB::PythonRunnerConfig
 Script execution configuration. More...
class  UTILSLIB::PythonRunner
 Python script launcher with logging and progress support. More...

Namespaces

namespace  UTILSLIB
 Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).

Typedefs

using UTILSLIB::PythonLineCallback = std::function<void(int channel, const QString& line)>
using UTILSLIB::PythonProgressCallback = std::function<void(float pct, const QString& msg)>

Detailed Description

Embedding-free launcher that runs MNE-Python (or any user) scripts as a child process and streams their output back to the C++ caller.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2026 MNE-CPP Authors

Author
Christoph Dinh chris.nosp@m.toph.nosp@m..dinh.nosp@m.@mne.nosp@m.-cpp..nosp@m.org
Since
2.2.0
Date
April 2026

UTILSLIB::PythonRunner wraps QProcess with the boilerplate needed to use Python for cross-validation, reference data generation and pipeline glue without linking against libpython: interpreter discovery, -u unbuffered launch for real-time streaming, line-level stdout/stderr callbacks, a tiny [progress] <pct>% protocol parsed into structured progress events, optional virtual-environment activation, and one-shot pip install of a pyproject directory or requirements.txt before the actual run.

The runner is the foundation under PythonTestHelper (used by every cross-language unit test) and under the mne-cpp applications that call MNE-Python utilities such as mne.coreg or mne.gui.report directly.

Definition in file python_runner.h.