Skip to content

Commit fd1dfc9

Browse files
committed
Fix faiss ModuleNotFoundError and scripts resolution
- ML_VENV_DIR/ML_VENV_PYTHON now always point to ~/.auto_note/venv/ instead of DATA_DIR/venv/ — in dev mode DATA_DIR=PROJECT_DIR so the old path never existed, leaving PYTHON as system python3 (no faiss) - PYTHON is now set to the venv at module init time (not deferred to _load_python_from_config) so it is correct before any command runs - Replace SCRIPTS dict literals with _script() helper that falls back to PROJECT_DIR when SCRIPTS_DIR/name doesn't exist — fixes dev-mode where scripts live in the project root, not a scripts/ subdirectory
1 parent 877a117 commit fd1dfc9

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

gui.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,18 @@
2222
# ── Project layout ────────────────────────────────────────────────────────────
2323

2424
PROJECT_DIR = Path(__file__).parent
25-
if getattr(sys, "frozen", False):
25+
26+
# The ML venv is always at ~/.auto_note/venv/ regardless of frozen/dev mode.
27+
# (The installer creates it there; dev mode uses it directly.)
28+
_VENV_SUBPATH = "Scripts/python.exe" if sys.platform == "win32" else "bin/python"
29+
ML_VENV_DIR = Path.home() / ".auto_note" / "venv"
30+
ML_VENV_PYTHON = str(ML_VENV_DIR / _VENV_SUBPATH)
31+
32+
# Initial Python: prefer the managed venv if already installed; otherwise
33+
# fall back to sys.executable (dev mode) or system python3 (frozen/AppImage).
34+
if Path(ML_VENV_PYTHON).exists():
35+
PYTHON = ML_VENV_PYTHON
36+
elif getattr(sys, "frozen", False):
2637
import shutil as _shutil
2738
PYTHON = _shutil.which("python3") or _shutil.which("python") or "python3"
2839
else:
@@ -38,8 +49,8 @@
3849
DATA_DIR = PROJECT_DIR
3950
DATA_DIR.mkdir(parents=True, exist_ok=True)
4051

41-
# Pipeline scripts are installed to ~/.auto_note/scripts/ so they run from a
42-
# persistent location instead of the temporary AppImage mount under /tmp.
52+
# Pipeline scripts are installed to ~/.auto_note/scripts/ in AppImage mode.
53+
# In dev mode the scripts live directly in PROJECT_DIR (no scripts/ subdir).
4354
SCRIPTS_DIR = DATA_DIR / "scripts"
4455

4556

@@ -59,20 +70,23 @@ def _install_scripts() -> None:
5970
_sh.copy2(str(src), str(dst))
6071

6172

73+
def _script(name: str) -> Path:
74+
"""Return the path to a pipeline script, falling back to PROJECT_DIR in dev mode."""
75+
installed = SCRIPTS_DIR / name
76+
if installed.exists():
77+
return installed
78+
return PROJECT_DIR / name # dev mode: scripts are in the project root
79+
80+
6281
SCRIPTS = {
63-
"downloader": SCRIPTS_DIR / "downloader.py",
64-
"transcribe": SCRIPTS_DIR / "extract_caption.py",
65-
"align": SCRIPTS_DIR / "semantic_alignment.py",
66-
"generate": SCRIPTS_DIR / "note_generation.py",
82+
"downloader": _script("downloader.py"),
83+
"transcribe": _script("extract_caption.py"),
84+
"align": _script("semantic_alignment.py"),
85+
"generate": _script("note_generation.py"),
6786
}
6887

6988
_DEFAULT_PYTHON = PYTHON # auto-detected fallback; may be overridden by user config
7089

71-
ML_VENV_DIR = DATA_DIR / "venv"
72-
ML_VENV_PYTHON = str(ML_VENV_DIR / (
73-
"Scripts/python.exe" if sys.platform == "win32" else "bin/python"
74-
))
75-
7690
# ML packages needed by the pipeline scripts (GUI requirements are bundled separately)
7791
_ML_PACKAGES = [
7892
"tqdm",

0 commit comments

Comments
 (0)