diff --git a/bash/functions/infra/write_jupyter_launcher.sh b/bash/functions/infra/write_jupyter_launcher.sh index afcb0aef..08880300 100644 --- a/bash/functions/infra/write_jupyter_launcher.sh +++ b/bash/functions/infra/write_jupyter_launcher.sh @@ -34,6 +34,11 @@ echo $PORT > .jupyter-port source .venv/bin/activate 2>/dev/null || true +# IPython startup: cargar .ipython/ local (FN_REGISTRY_ROOT, helpers, sys.path) +if [ -d "$(pwd)/.ipython" ]; then + export IPYTHONDIR="$(pwd)/.ipython" +fi + if ! python -c "import jupyter_collaboration" 2>/dev/null; then echo "ERROR: jupyter-collaboration no esta instalado" echo "Instala con: uv add jupyter-collaboration" diff --git a/bash/functions/infra/write_jupyter_registry_kernel.sh b/bash/functions/infra/write_jupyter_registry_kernel.sh index 79d46b83..e7a85379 100644 --- a/bash/functions/infra/write_jupyter_registry_kernel.sh +++ b/bash/functions/infra/write_jupyter_registry_kernel.sh @@ -33,7 +33,24 @@ import sqlite3 from pathlib import Path # ── FN_REGISTRY_ROOT ──────────────────────────────────────── -FN_REGISTRY_ROOT = Path("${registry_root}") +# Prioridad: env var > path hardcoded > descubrimiento automatico +def _discover_registry_root(): + if os.environ.get("FN_REGISTRY_ROOT"): + return Path(os.environ["FN_REGISTRY_ROOT"]).resolve() + hardcoded = Path("${registry_root}") + if (hardcoded / "registry.db").exists(): + return hardcoded + # Subir desde CWD hasta encontrar registry.db + p = Path.cwd() + for _ in range(10): + if (p / "registry.db").exists(): + return p + if p.parent == p: + break + p = p.parent + return hardcoded + +FN_REGISTRY_ROOT = _discover_registry_root() os.environ["FN_REGISTRY_ROOT"] = str(FN_REGISTRY_ROOT) # ── sys.path: importar funciones Python del registry ────────