Device lock (hardware lock of the DSP, independent of the app lock): - detect a locked DSP from the 0x2C answer during connect and wait for the code - unlock with 0x2D, optionally remember the code and unlock automatically - set a new code (0x2F) from the device settings - simulator: --lock CODE Demo mode: - switch in the settings starts a simulated DSP 204/408 inside the server - real DSPs are disconnected and greyed out meanwhile and resume afterwards - demo devices are never saved or exported; sim.py ships with the Pi image and EXEs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.6 KiB
Python
64 lines
2.6 KiB
Python
"""Builds the desktop programs into dist/:
|
|
|
|
python -m pip install pyinstaller pywebview pillow
|
|
python packaging/build.py
|
|
|
|
Windows:
|
|
dist/DSP Control.exe desktop app (own window, no PIN; optional remote access with PIN)
|
|
dist/DSP Control Pi Writer.exe SD card writer for a Raspberry Pi running the WebUI
|
|
macOS:
|
|
dist/DSP Control.app the same desktop app
|
|
dist/DSP Control.dmg disk image with the app and a link to /Applications
|
|
"""
|
|
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
SEP = ";" if sys.platform == "win32" else ":"
|
|
|
|
|
|
def pyinstaller(*args, onefile=True):
|
|
cmd = [sys.executable, "-m", "PyInstaller", "--noconfirm", "--onefile" if onefile else "--onedir", "--windowed",
|
|
"--distpath", str(ROOT / "dist"), "--workpath", str(ROOT / "build"), "--specpath", str(ROOT / "build"), *args]
|
|
print(">", " ".join(cmd))
|
|
subprocess.run(cmd, cwd=ROOT, check=True)
|
|
|
|
|
|
def data(src, dest="."):
|
|
return ["--add-data", f"{ROOT / src}{SEP}{dest}"]
|
|
|
|
|
|
def build_mac():
|
|
app = ROOT / "dist" / "DSP Control.app"
|
|
pyinstaller("--name", "DSP Control", "--icon", str(ROOT / "packaging" / "dsp-control.icns"),
|
|
"--osx-bundle-identifier", "at.thiemoo.dspcontrol", *data("static", "static"),
|
|
str(ROOT / "desktop.py"), onefile=False) # a .app bundle is always a folder
|
|
shutil.rmtree(ROOT / "dist" / "DSP Control", ignore_errors=True) # the loose onedir copy next to the .app
|
|
dmg = ROOT / "dist" / "DSP Control.dmg"
|
|
dmg.unlink(missing_ok=True)
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
shutil.copytree(app, Path(tmp) / app.name, symlinks=True)
|
|
(Path(tmp) / "Applications").symlink_to("/Applications")
|
|
subprocess.run(["hdiutil", "create", "-volname", "DSP Control", "-srcfolder", tmp, "-ov",
|
|
"-format", "UDZO", str(dmg)], check=True)
|
|
print("\nDone:", app.name, dmg.name, sep="\n ")
|
|
|
|
|
|
subprocess.run([sys.executable, str(ROOT / "packaging" / "make_icons.py")], check=True)
|
|
|
|
if sys.platform == "darwin":
|
|
build_mac()
|
|
sys.exit()
|
|
|
|
pyinstaller("--name", "DSP Control", "--icon", str(ROOT / "packaging" / "dsp-control.ico"),
|
|
*data("static", "static"), str(ROOT / "desktop.py"))
|
|
|
|
pyinstaller("--name", "DSP Control Pi Writer", "--icon", str(ROOT / "packaging" / "pi-writer.ico"), "--uac-admin",
|
|
*data("server.py"), *data("sim.py"), *data("dsp", "dsp"), *data("static", "static"), str(ROOT / "pi_writer.py"))
|
|
|
|
print("\nDone:", *(p.name for p in (ROOT / "dist").glob("*.exe")), sep="\n ")
|