Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(installer): isolate headless Linux venvs and tolerate host-only pip check conflicts (#1088)
Ruben Lütkea52cd904fe77
diff --git a/docs/supply-chain/threat-model.md b/docs/supply-chain/threat-model.mdindex 352057384b..74132a9ec7 100644--- a/docs/supply-chain/threat-model.md+++ b/docs/supply-chain/threat-model.md@@ -999,9 +999,10 @@ over a failure.containerization.- **`pyproject.toml` runtime deps are not themselves hash-pinned.**The pinning lives in `requirements.txt`; `pyproject.toml` carries- version ranges (e.g. `pydantic>=2.9,<3.0`). A user who installs via- `pip install -e .` (headless branch) gets the latest matching- versions from PyPI without hash checks. Hardening this requires+ version ranges (e.g. `pydantic>=2.9,<3.0`). The installer installs+ both profiles from the hashed lockfile (the headless branch moved to+ it in #456), but a user who runs `pip install -e .` by hand gets the+ latest matching versions from PyPI without hash checks. Hardening this requiresembedding hashes into PEP 631 dependency declarations, which isnot standardised. Wave 6.2 will look at the `[tool.uv.sources]`hash-pinning extension if uv stabilises that surface.diff --git a/install/install.sh b/install/install.shindex 0559fb8c4f..cadfd2cf92 100755--- a/install/install.sh+++ b/install/install.sh@@ -1440,24 +1440,44 @@ if [ -x "$VENV_PYTHON" ]; thenrm -rf "$VENV_PATH"fifi-# Linux venvs include system site-packages (deep-dive 2026-07-15, H-01): the-# GTK webview backend (python3-gi) and the optional accessibility tree-# (pyatspi) are GObject-Introspection DISTRO packages that pip cannot install-# and an isolated venv cannot import. The venv's own installs still shadow-# system packages on sys.path. Existing isolated Linux venvs are rebuilt once —-# packages are reinstalled by the installer right after, so nothing is lost.-if [ -x "$VENV_PYTHON" ] && [ "$(uname -s 2>/dev/null)" = "Linux" ] &&- grep -qi 'include-system-site-packages *= *false' "$VENV_PATH/pyvenv.cfg" 2>/dev/null; then- note 'rebuilding the Python environment (linking distro webview/accessibility packages)'- rm -rf "$VENV_PATH"+# Linux DESKTOP venvs include system site-packages (deep-dive 2026-07-15,+# H-01): the GTK webview backend (python3-gi) and the optional accessibility+# tree (pyatspi) are GObject-Introspection DISTRO packages that pip cannot+# install and an isolated venv cannot import. A --headless install uses+# neither, and linking the host's site-packages made pip treat whatever the+# host had installed (fastapi, uvicorn, opentelemetry, ...) as "already+# satisfied", so the server ran on host versions instead of the lockfile+# (#456) and `pip check` failed on host-only conflicts (#1018). Headless venvs+# therefore stay isolated. An existing venv whose setting does not match the+# profile is rebuilt once; packages are reinstalled by the installer right+# after, so nothing is lost.+_venv_isolated=0+if [ "$(uname -s 2>/dev/null)" = "Linux" ]; then+ _want_headless=0+ for _arg in "$@"; do+ case "$_arg" in+ --headless) _want_headless=1 ;;+ --with-desktop) _want_headless=0; break ;;+ esac+ done+ _venv_isolated=$_want_headless+ if [ -x "$VENV_PYTHON" ]; then+ if [ "$_venv_isolated" -eq 1 ] &&+ grep -qi 'include-system-site-packages *= *true' "$VENV_PATH/pyvenv.cfg" 2>/dev/null; then+ note 'rebuilding the Python environment (headless: isolated from host packages)'+ rm -rf "$VENV_PATH"+ elif [ "$_venv_isolated" -eq 0 ] &&+ grep -qi 'include-system-site-packages *= *false' "$VENV_PATH/pyvenv.cfg" 2>/dev/null; then+ note 'rebuilding the Python environment (linking distro webview/accessibility packages)'+ rm -rf "$VENV_PATH"+ fi+ fifiif [ ! -x "$VENV_PYTHON" ]; then- if [ "$(uname -s 2>/dev/null)" = "Linux" ]; then- run_spin 'creating the virtual environment' \- "$PYTHON_EXE" -m venv --system-site-packages "$VENV_PATH"+ if [ "$(uname -s 2>/dev/null)" = "Linux" ] && [ "$_venv_isolated" -eq 0 ]; then+ run_spin 'creating the virtual environment' "$PYTHON_EXE" -m venv --system-site-packages "$VENV_PATH"else- run_spin 'creating the virtual environment' \- "$PYTHON_EXE" -m venv "$VENV_PATH"+ run_spin 'creating the virtual environment' "$PYTHON_EXE" -m venv "$VENV_PATH"fifiok 'virtual environment ready'diff --git a/install/installer.py b/install/installer.pyindex 63271d225c..50a32bee18 100644--- a/install/installer.py+++ b/install/installer.py@@ -41,6 +41,7 @@ import argparseimport jsonimport osimport platform+import reimport shleximport shutilimport stat@@ -403,6 +404,138 @@ def installed_legacy_distributions() -> tuple[str, ...]:return tuple(found)+_PIP_CHECK_LINE = re.compile(+ r"^(?P<name>[A-Za-z0-9][A-Za-z0-9._-]*) \S+ "+ r"(?:has requirement |requires |is not supported on this platform)"+)++# Runs inside the venv's interpreter. For each distribution ``pip check``+# named, it answers whether that distribution is HOST-ONLY: installed outside+# the venv's own site-packages and not part of Dodaios' dependency closure+# (every extra counted, so the closure errs on the large side).+_HOST_ONLY_PROBE = r'''+import json, re, sys+from importlib import metadata+from pathlib import Path+from packaging.requirements import Requirement++def canon(name):+ return re.sub(r"[-_.]+", "-", name).lower()++venv = Path(sys.prefix).resolve()+needed = set()+queue = [("dodaios", None)]+while queue:+ name, extras = queue.pop()+ key = canon(name)+ if key in needed:+ continue+ needed.add(key)+ try:+ dist = metadata.distribution(name)+ except metadata.PackageNotFoundError:+ continue+ if extras is None:+ extras = set(dist.metadata.get_all("Provides-Extra") or [])+ for raw in dist.requires or []:+ req = Requirement(raw)+ if req.marker is not None and not any(+ req.marker.evaluate({"extra": extra}) for extra in ("", *extras)+ ):+ continue+ queue.append((req.name, set(req.extras)))++verdict = {}+for name in json.loads(sys.argv[1]):+ try:+ where = Path(metadata.distribution(name).locate_file("")).resolve()+ except metadata.PackageNotFoundError:+ verdict[canon(name)] = False+ continue+ inside = where == venv or venv in where.parents+ verdict[canon(name)] = not inside and canon(name) not in needed+print(json.dumps(verdict))+'''+++def _canonical_name(name: str) -> str:+ return re.sub(r"[-_.]+", "-", name).lower()+++def _pip_check_subjects(output: str) -> list[str] | None:+ """The distributions whose requirements ``pip check`` reported as broken.++ ``None`` when a line is not in a known form: an unknown report is never+ waved through.+ """+ subjects: list[str] = []+ for line in output.splitlines():+ line = line.strip()+ if not line or line.startswith(("WARNING:", "DEPRECATION:")):+ continue+ match = _PIP_CHECK_LINE.match(line)+ if match is None:+ return None+ subjects.append(match.group("name"))+ return subjects+++def _host_only_distributions(names: list[str]) -> dict[str, bool] | None:+ """Ask the venv's interpreter which of ``names`` are host-only (see the probe)."""+ try:+ result = subprocess.run(+ [str(venv_python()), "-c", _HOST_ONLY_PROBE, json.dumps(names)],+ cwd=repo_root(), capture_output=True, text=True,+ encoding="utf-8", errors="replace", timeout=120,+ )+ except (OSError, subprocess.TimeoutExpired):+ return None+ if result.returncode != 0:+ return None+ try:+ verdict = json.loads(result.stdout.strip().splitlines()[-1])+ except (ValueError, IndexError):+ return None+ return verdict if isinstance(verdict, dict) else None+++def dependency_check_passes(cmd: list[str], *, label: str) -> bool:+ """Run ``pip check``; tolerate conflicts that live only in host packages.++ A Linux desktop venv links the host's site-packages (install.sh, H-01), so+ ``pip check`` also judges packages the host installed for other tools. A+ broken requirement of such a package cannot affect Dodaios as long as the+ package lives outside the venv and Dodaios does not depend on it, yet it+ stopped whole updates (#1018). Those conflicts become a warning. Anything+ else, or a report this cannot read, stops the install as before.+ """+ try:+ result = run_captured(cmd, label=label, cwd=repo_root(), timeout=600)+ except (OSError, subprocess.TimeoutExpired) as exc:+ console.print(f"[bad]│ ✗ {label} could not run ({rich_escape(str(exc))})[/]")+ return False+ if result.returncode == 0:+ return True+ output = ((result.stdout or "") + "\n" + (result.stderr or "")).strip()+ subjects = _pip_check_subjects(output)+ verdict = _host_only_distributions(subjects) if subjects else None+ blocking = (+ None if verdict is None or subjects is None+ else [name for name in subjects if not verdict.get(_canonical_name(name))]+ )+ lines = output.splitlines()[-40:]+ if blocking is None or blocking:+ console.print(f"[bad]│ ✗ {label} found broken requirements[/]")+ for line in lines:+ console.print(f"[muted]│ {rich_escape(line)}[/]")+ return False+ note("warning: packages installed outside Dodaios' environment have broken")+ note("requirements; Dodaios does not use them, so the install continues:")+ for line in lines:+ note(f" {rich_escape(line)}")+ return True++def step_pip_install(*, with_desktop: bool, with_voice_local: bool, dry_run: bool) -> None:from scripts.native_crypto_index import pip_options@@ -416,19 +549,20 @@ def step_pip_install(*, with_desktop: bool, with_voice_local: bool, dry_run: boo# installs on Windows/macOS/Linux (each OS pulls only its wheels). Every# package-pinning line carries ``--hash=sha256:...`` so an attacker who compromises a PyPI# mirror cannot swap out a transitive dependency without invalidating- # the lockfile signature published in the GitHub Release. The desktop- # branch installs with ``--require-hashes`` so unhashed/mismatched- # entries fail-closed. The headless branch keeps ``pip install -e .`` —- # the cloud-first VPS path resolves from ``pyproject.toml`` directly- # because the lockfile predates Wave 6 hash pinning on transient bumps- # and ``pip install --require-hashes`` is the new contract going- # forward. See ``docs/supply-chain/threat-model.md`` §11.+ # the lockfile signature published in the GitHub Release. Both profiles+ # install it with ``--require-hashes`` so unhashed/mismatched entries+ # fail-closed. The lockfile holds only the base dependencies, so the+ # headless profile stays on the torch-free base floor. Headless used to+ # resolve ``pip install -e .`` from the open ``pyproject.toml`` ranges+ # instead, and on a Linux venv that links the host's site-packages pip then+ # took any host copy as "already satisfied", so the server ran on host+ # versions (#456). Exact pins install venv-local copies unless the host has+ # the very same version. See ``docs/supply-chain/threat-model.md`` §11.+ lockfile = pip + ["install", "--require-hashes", "-r", "requirements.txt"]if with_desktop:- runtime_step = ("runtime dependencies (hash-pinned lockfile)",- pip + ["install", "--require-hashes", "-r", "requirements.txt"])+ runtime_step = ("runtime dependencies (hash-pinned lockfile)", lockfile)else:- runtime_step = ("runtime dependencies (cloud-first base)",- pip + ["install", *pip_options(), "-e", "."])+ runtime_step = ("runtime dependencies (cloud-first base, hash-pinned lockfile)", lockfile)plans: list[tuple[str, list[str]]] = []# The checkout used to be installed under the distribution's earlier name.@@ -468,7 +602,10 @@ def step_pip_install(*, with_desktop: bool, with_voice_local: bool, dry_run: booreturnfor label, cmd in plans:- rc = run_quiet(cmd, label=label, cwd=repo_root())+ if cmd[len(pip):] == ["check"]:+ rc = 0 if dependency_check_passes(cmd, label=label) else 1+ else:+ rc = run_quiet(cmd, label=label, cwd=repo_root())if rc != 0:# The advertised desktop install is the [full] profile. Continuing# after that profile fails would advertise a ready app without thediff --git a/tests/unit/install/test_install_sh_venv_isolation.py b/tests/unit/install/test_install_sh_venv_isolation.pynew file mode 100644index 0000000000..f821d7e168--- /dev/null+++ b/tests/unit/install/test_install_sh_venv_isolation.py@@ -0,0 +1,108 @@+"""install.sh keeps headless Linux venvs isolated from host packages (#456, #1018).++The venv block of install.sh runs on its own with stubbed helpers: ``uname``+answers Linux, ``run_spin`` records the venv command instead of running it.+"""++from __future__ import annotations++import shutil+import subprocess+import sys+from pathlib import Path++import pytest++INSTALL_SH = Path(__file__).resolve().parents[3] / "install" / "install.sh"+BLOCK_START = "# Linux DESKTOP venvs include system site-packages"+BLOCK_END = "ok 'virtual environment ready'"++pytestmark = pytest.mark.skipif(+ sys.platform == "win32" or shutil.which("bash") is None,+ reason="runs the POSIX shell block",+)+++def _venv_block() -> str:+ text = INSTALL_SH.read_text(encoding="utf-8")+ start = text.index(BLOCK_START)+ return text[start : text.index(BLOCK_END, start)]+++def _run(tmp_path: Path, args: list[str], existing: str | None) -> tuple[str, bool]:+ venv = tmp_path / ".venv"+ venv_python = venv / "bin" / "python"+ if existing is not None:+ venv_python.parent.mkdir(parents=True, exist_ok=True)+ venv_python.write_text("#!/bin/sh\n", encoding="utf-8")+ venv_python.chmod(0o755)+ (venv / "pyvenv.cfg").write_text(+ f"home = /usr/bin\ninclude-system-site-packages = {existing}\n",+ encoding="utf-8",+ )+ script = (+ "set -euo pipefail\n"+ "uname() { echo Linux; }\n"+ "note() { echo \"NOTE: $1\"; }\n"+ "run_spin() { shift; echo \"VENV: $*\"; }\n"+ f'VENV_PATH="{venv}"\n'+ f'VENV_PYTHON="{venv_python}"\n'+ 'PYTHON_EXE="python3"\n'+ + _venv_block()+ )+ result = subprocess.run(+ ["bash", "-s", "--", *args],+ input=script,+ capture_output=True,+ text=True,+ encoding="utf-8",+ timeout=10,+ )+ assert result.returncode == 0, result.stderr + result.stdout+ return result.stdout, venv_python.exists()+++def _created(out: str) -> str | None:+ for line in out.splitlines():+ if line.startswith("VENV: "):+ return line[len("VENV: ") :]+ return None+++def test_headless_creates_an_isolated_venv(tmp_path: Path) -> None:+ out, _ = _run(tmp_path, ["--headless", "--no-launch"], existing=None)+ created = _created(out)+ assert created is not None and "-m venv" in created+ assert "--system-site-packages" not in created+++def test_desktop_links_system_site_packages(tmp_path: Path) -> None:+ out, _ = _run(tmp_path, ["--no-launch"], existing=None)+ assert "--system-site-packages" in (_created(out) or "")+++def test_with_desktop_wins_over_headless(tmp_path: Path) -> None:+ out, _ = _run(tmp_path, ["--headless", "--with-desktop"], existing=None)+ assert "--system-site-packages" in (_created(out) or "")+++def test_headless_rebuilds_a_venv_that_links_host_packages(tmp_path: Path) -> None:+ out, still_there = _run(tmp_path, ["--headless"], existing="true")+ assert not still_there+ assert "isolated from host packages" in out+ assert "--system-site-packages" not in (_created(out) or "")+++def test_headless_keeps_an_already_isolated_venv(tmp_path: Path) -> None:+ out, still_there = _run(tmp_path, ["--headless"], existing="false")+ assert still_there+ assert _created(out) is None+ assert "rebuilding" not in out+++def test_desktop_keeps_a_matching_venv_and_rebuilds_an_isolated_one(tmp_path: Path) -> None:+ out, still_there = _run(tmp_path, [], existing="true")+ assert still_there and _created(out) is None+ out, still_there = _run(tmp_path, [], existing="false")+ assert not still_there+ assert "--system-site-packages" in (_created(out) or "")diff --git a/tests/unit/install/test_installer_flow.py b/tests/unit/install/test_installer_flow.pyindex 3e210f7bff..731a15cba2 100644--- a/tests/unit/install/test_installer_flow.py+++ b/tests/unit/install/test_installer_flow.py@@ -154,8 +154,7 @@ def test_headless_pip_plan_stays_base_floor(capsys) -> None:assert ".[desktop]" not in out[email protected]("desktop", [True, False])-def test_native_crypto_index_reaches_the_installer_profile(monkeypatch, desktop) -> None:+def test_native_crypto_index_reaches_the_installer_profile(monkeypatch) -> None:from scripts import native_crypto_indexoptions = native_crypto_index.pip_options("darwin", "x86_64")@@ -167,15 +166,44 @@ def test_native_crypto_index_reaches_the_installer_profile(monkeypatch, desktop)return 0monkeypatch.setattr(installer, "run_quiet", capture)+ monkeypatch.setattr(installer, "dependency_check_passes", lambda *_a, **_k: True)monkeypatch.setattr(installer, "repair_distribution_metadata", lambda **_kwargs: True)- installer.step_pip_install(with_desktop=desktop, with_voice_local=False, dry_run=False)- profile = ".[full]" if desktop else "."+ installer.step_pip_install(with_desktop=True, with_voice_local=False, dry_run=False)command = next(- command for command in commands if profile in command and "--no-deps" not in command+ command for command in commands if ".[full]" in command and "--no-deps" not in command)assert command[command.index("--find-links") + 1] == native_crypto_index.wheel_links_url()+def test_lockfile_carries_the_native_crypto_source() -> None:+ """Both profiles install requirements.txt, which names the scoped source itself."""+ from scripts import native_crypto_index++ lockfile = (REPO / "requirements.txt").read_text(encoding="utf-8")+ assert f"--find-links {native_crypto_index.wheel_links_url()}" in lockfile++[email protected]("desktop", [True, False])+def test_runtime_dependencies_come_from_the_hashed_lockfile(monkeypatch, desktop) -> None:+ """#456: headless no longer resolves open ranges against host packages."""+ commands = []++ def capture(command, **_kwargs):+ commands.append(command)+ return 0++ monkeypatch.setattr(installer, "run_quiet", capture)+ monkeypatch.setattr(installer, "dependency_check_passes", lambda *_a, **_k: True)+ monkeypatch.setattr(installer, "installed_legacy_distributions", lambda: ())+ monkeypatch.setattr(installer, "repair_distribution_metadata", lambda **_kwargs: True)+ installer.step_pip_install(with_desktop=desktop, with_voice_local=False, dry_run=False)+ pip = [str(installer.venv_python()), "-m", "pip"]+ tails = [command[len(pip):] for command in commands]+ assert ["install", "--require-hashes", "-r", "requirements.txt"] in tails+ # The only unpinned install of the checkout itself is the entry-point one.+ assert [tail for tail in tails if "." in tail] == [["install", "-e", ".", "--no-deps"]]++@pytest.mark.parametrize("update", [False, True])@pytest.mark.parametrize(("args", "display", "with_desktop"),diff --git a/tests/unit/install/test_installer_legacy_distribution.py b/tests/unit/install/test_installer_legacy_distribution.pyindex f54d413193..1ddf000f6e 100644--- a/tests/unit/install/test_installer_legacy_distribution.py+++ b/tests/unit/install/test_installer_legacy_distribution.py@@ -60,6 +60,7 @@ def _commands(monkeypatch, legacy: tuple[str, ...], *, desktop: bool) -> list[limonkeypatch.setattr(installer, "installed_legacy_distributions", lambda: legacy)monkeypatch.setattr(installer, "run_quiet", capture)+ monkeypatch.setattr(installer, "dependency_check_passes", lambda *_a, **_k: True)monkeypatch.setattr(installer, "repair_distribution_metadata", lambda **_kwargs: True)installer.step_pip_install(with_desktop=desktop, with_voice_local=False, dry_run=False)return commandsdiff --git a/tests/unit/install/test_installer_pip_check.py b/tests/unit/install/test_installer_pip_check.pynew file mode 100644index 0000000000..7339744696--- /dev/null+++ b/tests/unit/install/test_installer_pip_check.py@@ -0,0 +1,155 @@+"""The dependency check tolerates conflicts that live only in host packages (#1018).++A Linux desktop venv links the host's site-packages, so ``pip check`` also+judges packages other tools installed there. Those must not stop the install;+a broken requirement inside the venv, or anything Dodaios depends on, still+must.+"""++from __future__ import annotations++import importlib.util+import subprocess+import sys+from pathlib import Path++import pytest++REPO = Path(__file__).resolve().parents[3]+_spec = importlib.util.spec_from_file_location("installer", REPO / "install" / "installer.py")+installer = importlib.util.module_from_spec(_spec)+_spec.loader.exec_module(installer)++ISSUE_1018_REPORT = (+ "opentelemetry-exporter-otlp-proto-http 1.40.0 has requirement "+ "opentelemetry-sdk~=1.40.0, but you have opentelemetry-sdk 1.45.1.\n"+ "opentelemetry-exporter-otlp-proto-grpc 1.40.0 has requirement "+ "opentelemetry-sdk~=1.40.0, but you have opentelemetry-sdk 1.45.1.\n"+)+CMD = [sys.executable, "-m", "pip", "check"]+++def _pip_check_reports(monkeypatch, stdout: str, returncode: int = 1) -> None:+ def fake(cmd, **_kwargs):+ return subprocess.CompletedProcess(cmd, returncode, stdout=stdout, stderr="")++ monkeypatch.setattr(installer, "run_captured", fake)+++def test_report_lines_name_the_broken_distributions() -> None:+ report = ISSUE_1018_REPORT + (+ "WARNING: Skipping /usr/lib/python3/dist-packages/PyJWT-2.7.0.dist-info "+ "due to invalid metadata\n"+ "fastapi 0.138.2 requires starlette, which is not installed.\n"+ "pywin32 311 is not supported on this platform\n"+ )+ assert installer._pip_check_subjects(report) == [+ "opentelemetry-exporter-otlp-proto-http",+ "opentelemetry-exporter-otlp-proto-grpc",+ "fastapi",+ "pywin32",+ ]+++def test_an_unknown_report_line_is_never_waved_through() -> None:+ assert installer._pip_check_subjects("Traceback (most recent call last):\n") is None+++def test_a_clean_check_passes(monkeypatch) -> None:+ _pip_check_reports(monkeypatch, "No broken requirements found.\n", returncode=0)+ monkeypatch.setattr(+ installer, "_host_only_distributions", lambda _names: pytest.fail("no probe needed")+ )+ assert installer.dependency_check_passes(CMD, label="dependency consistency check")+++def test_host_only_conflicts_warn_and_continue(monkeypatch, capsys) -> None:+ _pip_check_reports(monkeypatch, ISSUE_1018_REPORT)+ asked = []++ def probe(names):+ asked.append(list(names))+ return {installer._canonical_name(name): True for name in names}++ monkeypatch.setattr(installer, "_host_only_distributions", probe)+ assert installer.dependency_check_passes(CMD, label="dependency consistency check")+ assert asked == [[+ "opentelemetry-exporter-otlp-proto-http",+ "opentelemetry-exporter-otlp-proto-grpc",+ ]]+ out = capsys.readouterr().out+ assert "warning" in out+ assert "opentelemetry-exporter-otlp-proto-http" in out+++def test_a_conflict_inside_the_venv_still_stops_the_install(monkeypatch, capsys) -> None:+ _pip_check_reports(monkeypatch, ISSUE_1018_REPORT)+ monkeypatch.setattr(+ installer,+ "_host_only_distributions",+ lambda names: {+ "opentelemetry-exporter-otlp-proto-http": True,+ "opentelemetry-exporter-otlp-proto-grpc": False,+ },+ )+ assert not installer.dependency_check_passes(CMD, label="dependency consistency check")+ assert "found broken requirements" in capsys.readouterr().out+++def test_a_failed_probe_stops_the_install(monkeypatch) -> None:+ _pip_check_reports(monkeypatch, ISSUE_1018_REPORT)+ monkeypatch.setattr(installer, "_host_only_distributions", lambda _names: None)+ assert not installer.dependency_check_passes(CMD, label="dependency consistency check")+++def test_a_failing_check_exits_the_pip_step(monkeypatch) -> None:+ monkeypatch.setattr(installer, "run_quiet", lambda *_a, **_k: 0)+ monkeypatch.setattr(installer, "installed_legacy_distributions", lambda: ())+ monkeypatch.setattr(installer, "repair_distribution_metadata", lambda **_kwargs: True)+ monkeypatch.setattr(installer, "dependency_check_passes", lambda *_a, **_k: False)+ with pytest.raises(SystemExit, match="2"):+ installer.step_pip_install(with_desktop=False, with_voice_local=False, dry_run=False)+++def _dist_info(site: Path, name: str, version: str, requires: tuple[str, ...] = ()) -> None:+ info = site / f"{name.replace('-', '_')}-{version}.dist-info"+ info.mkdir(parents=True)+ lines = ["Metadata-Version: 2.1", f"Name: {name}", f"Version: {version}"]+ lines += [f"Requires-Dist: {req}" for req in requires]+ (info / "METADATA").write_text("\n".join(lines) + "\n", encoding="utf-8")+++def test_the_probe_tells_host_only_packages_from_dodaios_dependencies(+ monkeypatch, tmp_path+) -> None:+ """Runs the real probe in a real venv that links the host's site-packages."""+ pytest.importorskip("packaging")+ venv = tmp_path / "venv"+ subprocess.run(+ [sys.executable, "-m", "venv", "--without-pip", "--system-site-packages", str(venv)],+ check=True, timeout=120,+ )+ python = venv / ("Scripts/python.exe" if sys.platform == "win32" else "bin/python")+ venv_site = Path(subprocess.run(+ [str(python), "-c", "import sysconfig; print(sysconfig.get_paths()['purelib'])"],+ check=True, capture_output=True, text=True, timeout=60,+ ).stdout.strip())+ host_site = tmp_path / "host-site-packages"+ _dist_info(venv_site, "dodaios", "0.0.0", ("host-needed>=1",))+ _dist_info(venv_site, "venv-local", "1.0")+ _dist_info(host_site, "host-needed", "1.0")+ _dist_info(host_site, "host-unrelated", "1.0")+ monkeypatch.setattr(installer, "venv_python", lambda: python)+ monkeypatch.setattr(installer, "repo_root", lambda: tmp_path)+ monkeypatch.setenv("PYTHONPATH", str(host_site))++ verdict = installer._host_only_distributions(+ ["host-unrelated", "host_needed", "venv-local", "not-installed-anywhere"]+ )++ assert verdict == {+ "host-unrelated": True, # outside the venv and unused: tolerable+ "host-needed": False, # Dodaios depends on it: never tolerated+ "venv-local": False, # lives inside the venv+ "not-installed-anywhere": False,+ }