diff --git a/scripts/install.sh b/scripts/install.sh index 9562792..52092c5 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -132,6 +132,10 @@ cp -r "$SOURCE_DIR/bin" "$INSTALL_DIR/" cp -r "$SOURCE_DIR/lib" "$INSTALL_DIR/" cp -r "$SOURCE_DIR/etc" "$INSTALL_DIR/" +if [[ -d "$SOURCE_DIR/tui" ]]; then + cp -r "$SOURCE_DIR/tui" "$INSTALL_DIR/" +fi + if [[ -d "$SOURCE_DIR/scripts" ]]; then cp -r "$SOURCE_DIR/scripts" "$INSTALL_DIR/" fi @@ -143,6 +147,21 @@ fi # Make entrypoint executable chmod +x "$INSTALL_DIR/bin/gniza" +# ── Install Python TUI dependencies ───────────────────────── +if command -v python3 &>/dev/null; then + info "Installing Python TUI dependencies (textual, textual-serve)..." + if python3 -m pip install --break-system-packages textual textual-serve 2>/dev/null; then + info "Python TUI dependencies installed." + elif python3 -m pip install textual textual-serve 2>/dev/null; then + info "Python TUI dependencies installed." + else + warn "Could not install Python TUI dependencies. TUI/web mode may not work." + warn "Install manually: pip3 install textual textual-serve" + fi +else + warn "python3 not found. TUI mode will not be available." +fi + # ── Create symlink ─────────────────────────────────────────── info "Creating symlink: $BIN_LINK -> $INSTALL_DIR/bin/gniza" mkdir -p "$(dirname "$BIN_LINK")" diff --git a/tui/__main__.py b/tui/__main__.py index f4eb6d4..1928da5 100644 --- a/tui/__main__.py +++ b/tui/__main__.py @@ -4,8 +4,8 @@ from pathlib import Path from tui.app import GnizaApp -# Resolve project root (parent of tui/) -_PROJECT_ROOT = str(Path(__file__).resolve().parent.parent) +# Use GNIZA_DIR from env (set by bin/gniza), fall back to parent of tui/ +_ROOT = os.environ.get("GNIZA_DIR", str(Path(__file__).resolve().parent.parent)) def main(): @@ -15,8 +15,8 @@ def main(): for i, arg in enumerate(sys.argv): if arg == "--port" and i + 1 < len(sys.argv): port = int(sys.argv[i + 1]) - os.environ["PYTHONPATH"] = f"{_PROJECT_ROOT}:{os.environ.get('PYTHONPATH', '')}" - os.environ["GNIZA_DIR"] = _PROJECT_ROOT + os.environ["PYTHONPATH"] = f"{_ROOT}:{os.environ.get('PYTHONPATH', '')}" + os.environ["GNIZA_DIR"] = _ROOT server = Server("python3 -m tui", host="0.0.0.0", port=port, title="gniza") server.serve() else: