diff --git a/feedback_inbox/feedback_inbox/tests/test_install.py b/feedback_inbox/feedback_inbox/tests/test_install.py new file mode 100644 index 0000000..dc506c2 --- /dev/null +++ b/feedback_inbox/feedback_inbox/tests/test_install.py @@ -0,0 +1,34 @@ +# Copyright (c) 2026 Krzysztof Rudnicki +"""install.sh puts every declared dependency into the venv. + +The package itself is installed with --no-deps (no network at install time), +so each sibling package from pyproject's dependencies needs its own pip line. +A missing one made every service run die with ModuleNotFoundError +(kuhy_credit, 2026-11-21) and no bundle became a task. +""" + +from __future__ import annotations + +from pathlib import Path +import re +import tomllib + +ROOT = Path(__file__).resolve().parents[2] + + +def _sibling_dirs() -> list[str]: + """Return the utils subdirectory each declared dependency lives in.""" + project = tomllib.loads((ROOT / "pyproject.toml").read_text())["project"] + dirs = [] + for dep in project["dependencies"]: + match = re.search(r"subdirectory=([\w-]+)", dep) + assert match, f"dependency without a utils subdirectory: {dep}" + dirs.append(match.group(1)) + return dirs + + +def test_install_installs_every_dependency() -> None: + script = (ROOT / "install.sh").read_text() + for sub in _sibling_dirs(): + assert f'install --quiet --no-deps "$UTILS_DIR/{sub}"' in script, sub + assert (ROOT.parent / sub).is_dir(), sub diff --git a/feedback_inbox/install.sh b/feedback_inbox/install.sh index 0bde12e..959141d 100755 --- a/feedback_inbox/install.sh +++ b/feedback_inbox/install.sh @@ -14,6 +14,7 @@ set -euo pipefail REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" readonly REPO_DIR +readonly UTILS_DIR="${REPO_DIR%/*}" readonly STATE_DIR="${HOME}/.local/share/feedback-inbox" readonly VENV_DIR="${STATE_DIR}/venv" readonly BIN_DIR="${HOME}/.local/bin" @@ -35,8 +36,12 @@ build_venv() { mkdir -p "$STATE_DIR" [[ -x "$VENV_DIR/bin/python" ]] || "$SYSTEM_PYTHON" -m venv "$VENV_DIR" \ || fail "could not create the venv" + # One line per pyproject dependency (tests/test_install.py): the package + # itself goes in with --no-deps, so a missing line kills every run. + "$VENV_DIR/bin/pip" install --quiet --no-deps "$UTILS_DIR/kuhy_credit" \ + || fail "the kuhy_credit sibling package" "$VENV_DIR/bin/pip" install --quiet --no-deps -e "$REPO_DIR" \ - || fail "feedback-inbox itself (stdlib only, no other packages)" + || fail "feedback-inbox itself" mkdir -p "$BIN_DIR" ln -sf "$VENV_DIR/bin/feedback-inbox" "$BIN_DIR/feedback-inbox" }