The Layered Install and Lazy Imports

g.Pype installs in layers, so a machine gets only what it needs: a headless server takes no Qt and no device drivers. And import gpype loads none of the optional layers; each is imported when a node first needs it.

pip install gpype installs the core, with no Qt. Four extras add the GUI, the device drivers, LSL and the non-CSV file formats, and all installs the four. import gpype loads none of them.

The layers

pip install gpype is what a server needs: every processing node, CSV recording and replay, UDP, the Collector, saving and loading serialized pipelines – and no Qt. Four extras add the rest:

Extra

Installs

For

gui

PySide6, pyqtgraph

MainApp, the scopes and widgets

devices

gtec-ble, gtec_gds, gtec-unicorn, pynput; gtec_pp on Windows

the amplifiers, Keyboard, ParadigmPresenter

lsl

pylsl

LSLSender, LslReceiver

formats

h5py, pyedflib

the .h5, .mat and .edf writers and readers

A lab PC with a screen and amplifiers takes all four extras, with pip install "gpype[all]" – what a plain pip install gpype gave before version 4.0. Extras also combine: a headless acquisition box might take pip install "gpype[devices,lsl]" (the quotes keep shells such as zsh from reading the brackets). gtec-unicorn installs on Windows x64, Linux x86_64 and macOS arm64, and gtec_pp, which drives Paradigm Presenter, on Windows only.

Lazy imports

import gpype took 0.02 s when measured, and loaded none of PySide6, pyqtgraph, the device drivers, pylsl, h5py, pyedflib or pynput. Naming a class – gp.TimeSeriesScope, gp.GNautilus – loads none of them either. A package is imported when a node first needs it, and not before.

For most device nodes that moment is start(), not construction: gp.BCICore() and gp.Keyboard() build without importing their drivers. That is what lets a server build a node to describe a stream it only receives, and read a serialized pipeline that names an amplifier it does not have. The GDS amplifiers are the exception: they open their device, and so import their driver, when you construct them.

A missing extra says which one. Using a node whose package is not installed raises an error that names the extra and the command, rather than a bare No module named ...:

AttributeError: gpype.LSLSender needs a package that is not installed.
'pylsl' is provided by the 'lsl' extra, which `pip install gpype` no longer
installs on its own:
    pip install 'gpype[lsl]'

A widget needs its window first. In an ordinary script, build the MainApp before any scope. Built the other way round, Qt would end the process without a word, so the scope refuses instead: “TimeSeriesScope needs a Qt application before it can be built. Create the app first: app = gp.MainApp()”.