1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# Building LabUI from Source
Produces a standalone `dist/LabUI/` directory (onedir, not onefile — required for tufup's per-file update patching).
PyInstaller does not cross-compile — build on the same OS you're targeting. For Windows, build on Windows. For Linux, build on Linux (WSL2 works fine if your day-to-day machine is Windows — it produces a real Linux ELF binary, no cross-compilation involved). Each OS gets its own independent TUF signing setup (see below) and its own release tag, since a Windows build and a Linux build of the same version are different byte-for-byte archives.
## Prerequisites
Python 3.10+ and the dev requirements:
```bash
pip install -r requirements.txt
pip install -r requirements-dev.txt
```
`requirements-dev.txt` adds PyInstaller and tufup on top of the runtime deps.
## First-time setup — TUF repository (once per platform)
Skip this for a given platform if `scripts/release/<platform>/keystore/` already exists (i.e. someone else on the team has already initialised that platform's repo and shared the keystore out-of-band). `<platform>` is `win`, `linux`, or `mac` — `repo_init.py` picks it automatically based on the OS you run it on.
```bash
python scripts/release/repo_init.py
```
This generates, under `scripts/release/<platform>/`:
- `keystore/` — private + public keys for the TUF root/targets/snapshot/timestamp roles for *this platform*. **Back this up somewhere private outside the repo. Losing a platform's root key means that platform's existing installs can never receive trusted updates again** (other platforms are unaffected — keys are fully independent per platform).
- `repository/` — initial signed TUF metadata for this platform, including `root.json`.
After init, build once more so the freshly-generated `root.json` gets bundled into the app (the `.spec` file only includes it if it already exists, and reads it from this same platform's tree):
```bash
pyinstaller labui.spec
```
## Building a release (repeat per platform, on that platform)
### 1. Bump the version
Edit `core/version.py`:
```python
__version__ = "1.2.3"
```
This single value is read by the auto-updater at runtime (`core/updater.py`) and by the release script when signing the new target. Use the same version number across all platforms for one release, even though each is built/signed/published as a separate step.
### 2. Build the executable
```bash
pyinstaller labui.spec
```
Output: `dist/LabUI/LabUI` (Linux/macOS) or `dist/LabUI/LabUI.exe` (Windows) — whichever OS you're currently running on.
The build bundles:
- `ui/style_dark.qss` and `ui/style_light.qss`
- `scripts/release/<platform>/repository/metadata/root.json` (if present — enables trusted updates on fresh installs; `<platform>` auto-detected from the OS running PyInstaller)
Plugins are **not bundled**. They are installed at runtime by the user via **Settings → Plugins → Install Plugin…**. Installed plugins and their enabled state live in `~/.labui/plugins/`. Plugin pip dependencies (for machines without Python) land in `~/.labui/plugin_packages/`, which is added to `sys.path` at startup.
### 3. Sign the release target
```bash
python scripts/release/repo_release.py
```
Creates and signs `scripts/release/<platform>/repository/targets/labui-<version>.tar.gz` and updates the TUF metadata files in `scripts/release/<platform>/repository/metadata/`.
### 4. Publish to GitHub
Upload every file from `scripts/release/<platform>/repository/metadata/` and `scripts/release/<platform>/repository/targets/` to the GitHub Release tagged **`updates-<platform>`** (e.g. `updates-win`, `updates-linux` — fixed tag per platform, not a version tag), replacing any same-named files already there.
The app's updater always points at `.../releases/download/updates-<platform>/` (platform auto-detected at runtime by `core.updater._platform_key()`), so each platform's tag must stay constant across versions. Don't share one tag across platforms — TUF metadata filenames (`root.json`, `timestamp.json`, ...) aren't platform-prefixed, so one platform's publish would silently overwrite the other's trust root.
A bare `LabUI.exe` does **not** belong on the `updates-<platform>` release — the updater only looks for the TUF metadata + target archive described above; a loose exe there does nothing.
Optionally create a separate human-facing release with a changelog under a version tag (e.g. `v1.2.3`) for people downloading the app for the first time (TUF only handles *updating* an already-installed copy). Since the build is onedir, zip the whole `dist/LabUI/` folder for that release rather than attaching the bare exe — the exe alone won't run without its sibling files. If you support multiple platforms, attach one zip per platform to that same version-tagged release.
### 5. Verify
Launch a previous installed version of this platform → Settings → Check for Updates → confirm it finds and applies the new version.
## Re-signing expired metadata
TUF metadata expires even with no new release (`root`: 365 days, others: 90 days) — independently per platform. If metadata goes stale before the next release for a given platform, that platform's clients reject it. Re-sign:
```bash
python -m tufup sign snapshot scripts/release/<platform>/keystore
python -m tufup sign timestamp scripts/release/<platform>/keystore
```
Run from the repo root, substituting the actual platform directory. Re-upload the resulting files to that platform's `updates-<platform>` release.
## What's bundled vs. external
| Item | Bundled in exe? | Notes |
|------|----------------|-------|
| Python runtime | Yes | PyInstaller includes it |
| PyQt6 / pyqtgraph / numpy | Yes | |
| QSS theme files | Yes | copied from `ui/` |
| Plugins | No | installed by users into `~/.labui/plugins/` at runtime |
| Plugin pip deps | No | installed into `~/.labui/plugin_packages/` or vendored inside plugin zip |
| `root.json` | Yes (if present) | TUF trust bootstrap, this platform's own copy |
| `nidaqmx` | No | optional; NI runtime is Windows-only, must be installed separately |
| `opencv-python` | No | optional; only needed if a plugin requires it (vendor it in the plugin zip) |
## Troubleshooting
**`ModuleNotFoundError` at launch** — a hidden import PyInstaller missed. Add it to `hiddenimports` in `labui.spec` and rebuild.
**Plugin not loading in built app** — plugins are not bundled; the user must install them via Settings → Plugins. If the plugin loads but fails silently, check that its `vendor/` folder contains all required packages, or that the user has pip-installed them (they land in `~/.labui/plugin_packages/`).
**Plugin dependency not importable after pip install** — the user may need to restart the app so `~/.labui/plugin_packages/` is injected into `sys.path` (this happens in `main.py` at startup).
**`root.json` not bundled** — run `repo_init.py` first (see First-time setup), then rebuild, on this same platform.
**Updates work on one platform but not another** — check each platform published to its own `updates-<platform>` tag, not a shared `updates` tag, and that `core.updater._platform_key()`'s mapping (`win`/`mac`/else-`linux`) matches the directory names under `scripts/release/`.
|