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(dictation): read the install dir from sys.path when the prefix is lost
rubenluetke10-beep5e76b5333ee7
diff --git a/jarvis/dictation/local_preview.py b/jarvis/dictation/local_preview.pyindex 62982c4fe6..d3be7c83b4 100644--- a/jarvis/dictation/local_preview.py+++ b/jarvis/dictation/local_preview.py@@ -119,6 +119,12 @@ def _child_python() -> str:for prefix in dict.fromkeys((sys.prefix, sys.base_prefix)):root = Path(prefix)dirs += [root / "Scripts", root] if sys.platform == "win32" else [root / "bin"]+ if sys.platform == "win32":+ # A relocated copy finds no prefix landmark, so ``sys.prefix`` (and the+ # frozen ``os.__file__``) fall back to the working directory. The+ # stdlib path the registry supplied is still on ``sys.path`` as+ # ``<install>\Lib`` / ``<install>\DLLs``, beside that install's python.exe.+ dirs += [Path(p).parent for p in sys.path if Path(p).name.lower() in ("lib", "dlls")]for directory in dirs:for name in names:candidate = directory / namediff --git a/tests/unit/dictation/test_local_preview.py b/tests/unit/dictation/test_local_preview.pyindex 75390e6698..78adfe7277 100644--- a/tests/unit/dictation/test_local_preview.py+++ b/tests/unit/dictation/test_local_preview.py@@ -463,6 +463,7 @@ def test_the_worker_interpreter_is_found_when_the_branded_exe_stands_alone(monkeypatch.setattr(sys, "executable", str(branded))monkeypatch.setattr(sys, "prefix", str(env))monkeypatch.setattr(sys, "base_prefix", str(tmp_path / "missing"))+ monkeypatch.setattr(sys, "path", [str(tmp_path / "missing" / "Lib")])assert local_preview._child_python() == str(interp)@@ -477,6 +478,30 @@ def test_a_missing_worker_interpreter_still_fails_loudly(monkeypatch, tmp_path):monkeypatch.setattr(sys, "executable", str(branded))monkeypatch.setattr(sys, "prefix", str(tmp_path / "nowhere"))monkeypatch.setattr(sys, "base_prefix", str(tmp_path / "nowhere"))+ monkeypatch.setattr(sys, "path", [str(tmp_path / "nowhere" / "Lib")])with pytest.raises(RuntimeError, match="no python interpreter"):local_preview._child_python()+++def test_a_relocated_copy_with_a_lost_prefix_finds_the_stdlib_install(monkeypatch, tmp_path):+ """Without a prefix landmark, ``sys.prefix`` is the working directory;+ the registry-supplied stdlib on ``sys.path`` still names the install."""+ import sys++ from jarvis.dictation import local_preview++ if sys.platform != "win32":+ pytest.skip("the relocated branded copy exists only on Windows")+ branded = tmp_path / "bin" / "PersonalJarvis.exe"+ branded.parent.mkdir()+ branded.write_bytes(b"")+ install = tmp_path / "Python311"+ (install / "Lib").mkdir(parents=True)+ (install / "python.exe").write_bytes(b"")+ monkeypatch.setattr(sys, "executable", str(branded))+ monkeypatch.setattr(sys, "prefix", str(tmp_path / "cwd"))+ monkeypatch.setattr(sys, "base_prefix", str(tmp_path / "cwd"))+ monkeypatch.setattr(sys, "path", ["", str(install / "Lib"), str(tmp_path / "cwd")])++ assert local_preview._child_python() == str(install / "python.exe")