From c3b382a5f6946eae3cbfc3b87dfa44f31ce97210 Mon Sep 17 00:00:00 2001 From: The Dust Council Date: Fri, 25 Sep 2026 08:29:20 -0700 Subject: [PATCH] Ask for what is needed, and nothing that is not An audit of the dependencies rather than a feature, prompted by being asked to make sure they were all listed. Four things were wrong, and one of them was wrong in the direction nobody checks. A dependency that was not one. The packaging asked for matplotlib, in a "plots" extra, and nothing in the program has ever imported it: the graphs a weather log turns into are drawn by this package's own PNG writer, the same one the waterfalls and the maps use. Anybody installing with that extra got a large package to no effect. Declarations are checked against imports in one direction as a matter of course -- an undeclared import fails on the first machine that is not the one it was written on -- and never in the other, where the failure is silent and costs somebody else's disk. Two speech engines that could not be installed. The transcriber takes five engines and the metadata offered extras for two of them, so openai-whisper and pocketsphinx were supported and unobtainable. They are alternatives rather than a set -- one is tiny and poor, one is the reference and slow -- so each has an extra of its own now. Nothing that can play a recording. The package suggested no audio player at all, so on a fresh install saunterbrowse's Enter key did nothing and there was no way to find out why. Recommended now, as any one of the three things that provide pw-play, paplay or aplay. Nothing that can open a map. The register's g key hands a coordinate to a browser, which needs something to start one; xdg-utils is suggested and the absence documented, since printing the coordinates instead is the useful answer on a headless receiver anyway. And the readme's list of audio players was simply wrong -- it named sox, left out mpv, and had the order it does not try them in. It is generated from the table the code actually uses now. Checked complete rather than assumed: the manual covers all seventeen subcommands, and the package ships every module, both manuals, the copyright, the readme and the install instructions. Nine tests so none of it drifts again, each confirmed by putting the defect back. The pair that matters checks the dependencies both ways: everything imported has to be asked for, and everything asked for has to be imported. The second of those is the one that had never existed, and is the one that would have caught matplotlib years ago. Full suite 2901 passed. Built as 2026-09-25_01. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_016PsWPTweCT6pwxKngvVxcg --- INSTALL.md | 2 + README.md | 4 +- bandsaunter/__init__.py | 2 +- packaging/bandsaunter.1 | 2 +- packaging/build-deb.sh | 5 +- packaging/saunterbrowse.1 | 2 +- pyproject.toml | 18 ++++- tests/test_licence.py | 161 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 186 insertions(+), 10 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index a1a6f32..f5cf4b6 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -180,6 +180,8 @@ of it, and says plainly when a feature is unavailable rather than failing. | `sudo apt install ffmpeg` | `bandsaunter flights --out sky.mp4` writes a video | a GIF is written instead, and it says so | | `sudo apt install espeak-ng` | clearer spoken timestamps on combined recordings, rendered about three times faster | a built-in formant synthesiser does the same job, less clearly | | `sudo apt install rtl-sdr` | `rtl_test`, `rtl_sdr` and friends, for diagnosing the hardware | nothing missing from bandsaunter itself | +| `sudo apt install pipewire-bin` (or `pulseaudio-utils`, or `alsa-utils`) | `saunterbrowse` plays a recording when you press Enter | the browser still reads transcripts and files recordings; only Enter has nothing to do. Over ssh there is usually no sound server anyway | +| `sudo apt install xdg-utils` | `g` in the register opens a station's place in a browser | it prints the coordinates instead, which on a headless receiver is the useful answer anyway | | `pip install faster-whisper` | speech transcription of recorded voice — see [the step-by-step below](#speech-transcription-step-by-step) (~250 MB installed, plus a 148 MB model) | transcription is off; scans report that no recogniser is installed | | `pip install vosk` | a smaller, weaker recogniser (~10 MB plus a 40 MB model) | as above | | `pip install openai-whisper` | the reference Whisper, slower and heavier than faster-whisper | as above | diff --git a/README.md b/README.md index f838bbe..de1f8b3 100644 --- a/README.md +++ b/README.md @@ -3625,8 +3625,8 @@ saunterbrowse --sort frequency # group by channel, not by time saunterbrowse --sort date/time # newest first: the default ``` -Playback is handed to whichever player is installed — `pw-play`, `paplay`, -`aplay`, `sox` or `ffplay`, in that order, or whatever `--player` names. The +Playback is handed to whichever player is installed — `pw-play`, `paplay`, `aplay`, `play`, `ffplay` or `mpv`, in that +order, or whatever `--player` names (`play` comes from `sox`). The recordings are ordinary WAVs and every desktop already has something that plays them; a browser that cannot start would be worse than one that cannot play. Over ssh, where there is usually no sound server at the far end, the diff --git a/bandsaunter/__init__.py b/bandsaunter/__init__.py index 6aad171..05ec1e8 100755 --- a/bandsaunter/__init__.py +++ b/bandsaunter/__init__.py @@ -8,7 +8,7 @@ and transcribing speech. # Versions are the release date and a revision within that day, so # 2026-08-21_02 is the second build made on the 21st. The revision is padded # to two digits so versions sort as text. -VERSION_DATE = "2026-09-24" +VERSION_DATE = "2026-09-25" VERSION_REVISION = 1 __version__ = f"{VERSION_DATE}_{VERSION_REVISION:02d}" diff --git a/packaging/bandsaunter.1 b/packaging/bandsaunter.1 index e18d96c..4358a87 100644 --- a/packaging/bandsaunter.1 +++ b/packaging/bandsaunter.1 @@ -1,5 +1,5 @@ .\" Generated by packaging/make-man.py -- do not edit by hand. -.TH BANDSAUNTER 1 "2026-09-24" "bandsaunter 2026-09-24_01" "User Commands" +.TH BANDSAUNTER 1 "2026-09-25" "bandsaunter 2026-09-25_01" "User Commands" .SH NAME bandsaunter \- scan, record and identify radio signals with an RTL-SDR .SH SYNOPSIS diff --git a/packaging/build-deb.sh b/packaging/build-deb.sh index 853166d..0f7dbac 100755 --- a/packaging/build-deb.sh +++ b/packaging/build-deb.sh @@ -76,8 +76,9 @@ Priority: optional Architecture: ${arch} Depends: python3 (>= 3.10), python3-numpy, python3-scipy, python3-rich, python3-yaml, librtlsdr0 -Recommends: bandsaunter-transcribe, espeak-ng -Suggests: rtl-sdr, python3-pyqt6, ffmpeg +Recommends: bandsaunter-transcribe, espeak-ng, + pipewire-bin | pulseaudio-utils | alsa-utils +Suggests: rtl-sdr, python3-pyqt6, ffmpeg, xdg-utils, mpv Maintainer: The Dust Council Homepage: https://frostwarning.com/git/dustcouncil/bandsaunter Installed-Size: $(du -ks "$pkgdir" | cut -f1) diff --git a/packaging/saunterbrowse.1 b/packaging/saunterbrowse.1 index 3d7adaa..a050f4e 100644 --- a/packaging/saunterbrowse.1 +++ b/packaging/saunterbrowse.1 @@ -1,5 +1,5 @@ .\" Generated by packaging/make-browse-man.py -- do not edit by hand. -.TH SAUNTERBROWSE 1 "2026-09-24" "bandsaunter 2026-09-24_01" "User Commands" +.TH SAUNTERBROWSE 1 "2026-09-25" "bandsaunter 2026-09-25_01" "User Commands" .SH NAME saunterbrowse \- read and listen to what a bandsaunter scan collected .SH SYNOPSIS diff --git a/pyproject.toml b/pyproject.toml index 494b6fd..1c1d950 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,17 +26,29 @@ Homepage = "https://frostwarning.com/git/dustcouncil/bandsaunter" Source = "https://frostwarning.com/git/dustcouncil/bandsaunter" [project.optional-dependencies] -# The realtime aircraft window. Optional on purpose: without it the passive -# capture, the terminal board and the drawn maps all work unchanged. +# The realtime windows -- the aircraft map, the APRS map. Optional on +# purpose: without them the passive capture, the terminal boards and the +# drawn maps all work unchanged. PyQt6 is what this asks for, but the code +# takes PyQt5, PySide6 or PySide2 as well, because distributions disagree +# about which they ship. window = ["PyQt6>=6.4"] -plots = ["matplotlib>=3.5"] # pyte is a terminal emulator, used by the resize tests to read back what # a real terminal would show. Those tests skip without it. dev = ["pytest>=7.0", "pyte>=0.8"] # Speech recognition for --transcribe. Optional: transcription is off by # default, and the scan says so plainly when no recogniser is installed. +# One extra per engine, because they are alternatives rather than a set -- +# `bandsaunter transcribe --engines` says what each is good and bad at. transcribe = ["faster-whisper>=1.0"] +transcribe-whisper = ["openai-whisper>=20230314"] transcribe-small = ["vosk>=0.3"] +transcribe-tiny = ["pocketsphinx>=5.0"] + +# There was a "plots" extra here asking for matplotlib. Nothing in the +# program has ever imported it -- the graphs a weather log turns into are +# drawn by this package's own PNG writer, the same one the waterfalls and +# the maps use -- so it installed a large dependency to no effect. A test +# now checks every extra against what is actually imported. # System packages, which pip cannot install. Recorded here so packaging does # not have to rediscover them: diff --git a/tests/test_licence.py b/tests/test_licence.py index cd2635c..ed14cee 100644 --- a/tests/test_licence.py +++ b/tests/test_licence.py @@ -319,3 +319,164 @@ def test_the_tile_server_is_told_where_to_look_this_program_up(): assert "bandsaunter/" in USER_AGENT assert REPOSITORY in USER_AGENT assert bandsaunter.__version__ in USER_AGENT + + +# --------------------------------------------------------------------------- +# What it needs to run +# --------------------------------------------------------------------------- + +# Import name to the name of the thing that provides it. Not derivable: +# "yaml" comes from PyYAML and "faster_whisper" from faster-whisper, and +# nothing in an import statement says so. +PROVIDES = { + "numpy": "numpy", + "scipy": "scipy", + "rich": "rich", + "yaml": "PyYAML", + "faster_whisper": "faster-whisper", + "whisper": "openai-whisper", + "vosk": "vosk", + "pocketsphinx": "pocketsphinx", +} + + +def _imported() -> set: + """Every third-party module the package imports, anywhere.""" + import ast + import sys + + out = set() + for path in sorted((ROOT / "bandsaunter").glob("*.py")): + for node in ast.walk(ast.parse(path.read_text())): + names = [] + if isinstance(node, ast.Import): + names = [a.name.split(".")[0] for a in node.names] + elif isinstance(node, ast.ImportFrom) and node.level == 0 \ + and node.module: + names = [node.module.split(".")[0]] + for name in names: + if name not in sys.stdlib_module_names \ + and name != "bandsaunter": + out.add(name) + return out + + +def _declared() -> set: + """Every distribution the packaging metadata asks for, lower-cased.""" + import tomllib + + body = tomllib.load(open(ROOT / "pyproject.toml", "rb"))["project"] + wanted = list(body.get("dependencies") or []) + for extra in (body.get("optional-dependencies") or {}).values(): + wanted.extend(extra) + out = set() + for spec in wanted: + out.add(re.split(r"[<>=!~\[ ]", spec, 1)[0].strip().lower()) + return out + + +def test_everything_the_code_imports_is_asked_for_somewhere(): + """An undeclared import is an installation that works on the machine it + was written on and nowhere else.""" + missing = [] + for name in sorted(_imported()): + provider = PROVIDES.get(name) + assert provider is not None, ( + f"{name} is imported and this test does not know what provides " + f"it -- add it to PROVIDES") + if provider.lower() not in _declared(): + missing.append(f"{name} (from {provider})") + assert not missing, f"imported but never declared: {missing}" + + +def test_nothing_is_asked_for_that_the_code_never_imports(): + """The other direction, which is how a "plots" extra sat in the metadata + asking for matplotlib that nothing had ever imported: a large dependency + installed to no effect, and nothing to notice.""" + # The tooling extras are not imported by the package and are not meant + # to be; everything else has to be. + tools = {"pytest", "pyte"} + imported = {PROVIDES[n].lower() for n in _imported() if n in PROVIDES} + stale = sorted(_declared() - imported - tools - {"pyqt6"}) + assert not stale, f"declared but never imported: {stale}" + + +def test_the_window_bindings_the_code_accepts_are_the_ones_documented(): + """Four bindings work, because distributions disagree about which they + ship. The metadata can only name one, so the documentation has to name + the rest or three of them are a secret.""" + from bandsaunter.livemap import BINDINGS + + body = (ROOT / "INSTALL.md").read_text() + for binding in BINDINGS: + assert binding in body, f"{binding} works and is not documented" + + +def test_every_player_the_browser_will_use_is_named_in_the_readme(): + """The list said sox and ffplay and left out mpv, and had the order + wrong. A list of what to install is no use if it is not the list.""" + from bandsaunter.browse import PLAYERS + + body = README.read_text() + for name, _args in PLAYERS: + assert f"`{name}`" in body, f"{name} is used and not documented" + + +def test_every_engine_the_transcriber_will_use_is_documented(): + from bandsaunter.transcribe import ENGINES + + body = (ROOT / "INSTALL.md").read_text() + for engine in ENGINES: + assert engine in body, f"{engine} is an engine and is not documented" + + +def test_the_speech_engines_the_code_can_import_are_all_installable(): + """Each is an alternative rather than part of a set, so each has an + extra of its own.""" + import tomllib + + body = tomllib.load(open(ROOT / "pyproject.toml", "rb"))["project"] + extras = body.get("optional-dependencies") or {} + joined = " ".join(" ".join(v) for k, v in extras.items() + if k.startswith("transcribe")).lower() + for provider in ("faster-whisper", "openai-whisper", "vosk", + "pocketsphinx"): + assert provider in joined, f"no extra installs {provider}" + + +def test_the_package_asks_for_what_it_needs_to_be_useful(): + """The control file, which is the only dependency list apt reads.""" + body = (ROOT / "packaging" / "build-deb.sh").read_text() + control = body[body.index("Package: bandsaunter"):] + # Hard requirements: without any of these it cannot start or cannot see + # a dongle. + for need in ("python3-numpy", "python3-scipy", "python3-rich", + "python3-yaml", "librtlsdr0"): + assert need in control, f"{need} is not in Depends" + # And the things that make it do everything it can do. + for offer in ("espeak-ng", "ffmpeg", "python3-pyqt6", "xdg-utils"): + assert offer in control, f"{offer} is not suggested or recommended" + # Something that can play a recording, or saunterbrowse's Enter key + # does nothing at all. + assert any(p in control for p in ("pipewire-bin", "pulseaudio-utils", + "alsa-utils")), \ + "nothing that can play a recording is asked for" + + +def test_the_manual_covers_every_command_the_program_takes(): + """A subcommand that is not in the manual is one nobody finds.""" + from bandsaunter.cli import build_parser + + page = (ROOT / "packaging" / "bandsaunter.1").read_text() + commands = build_parser()._subparsers._group_actions[0].choices + for name in commands: + assert name in page, f"{name} is a command and is not in the manual" + + +def test_the_package_ships_both_manuals_and_the_readme(): + """Checked against the build script rather than a built package, so it + holds on a machine that has not built one.""" + body = (ROOT / "packaging" / "build-deb.sh").read_text() + for wanted in ("bandsaunter.1", "saunterbrowse.1", "README.md", + "INSTALL.md", "copyright"): + assert wanted in body, f"{wanted} is not installed by the package"