feat(jobs): runtime Python embebido + cadena de fallback (issue 0033 fase B)
Permite distribuir graph_explorer.exe Windows sin dependencia de WSL
ni del .venv del registry. Tambien funciona en Linux como bundle
autocontenido portable.
Cambios:
1. tools/freeze_python_runtime.sh
- Linux: copia python-build-standalone (uv) ~87 MB,
elimina marker EXTERNALLY-MANAGED, instala wheels.
- Windows: descarga python-3.12.7-embed-amd64.zip oficial
(~12 MB), habilita site-packages, instala wheels via
pip install --target --platform win_amd64.
- Idempotente via runtime/.lock con SHA256 del estado.
- Lee python_runtime_deps del frontmatter de app.md.
2. jobs.cpp::cached_python_runtime() — resolver con cadena:
1. <exe_dir>/runtime/python/{python.exe|bin/python3} (embedded)
2. $FN_PYTHON (env)
3. <registry_root>/python/.venv/bin/python3 (registry_venv)
4. python3 del PATH (system)
Loggea procedencia al iniciar jobs_init.
3. POSIX run_subprocess: usa el runtime resuelto en lugar del
path hardcodeado.
4. Windows run_subprocess: ramifica por needs_wsl. Si embedded
o env, lanza Python Windows nativo via CreateProcessW
directamente (run_path tambien Windows nativo). Solo el
legacy registry_venv sigue por wsl.exe.
5. app.md: nuevos campos python_runtime: true y
python_runtime_deps: [requests, certifi, urllib3].
6. .gitignore extendido con runtime/, projects/, _vendored/,
.vendor.lock, binarios Go de enrichers.
Tests: 26/26 verde — 16 originales + 6 dispatcher fase A + 4
nuevos del resolver fase B (con/sin embed, FN_PYTHON, idempotencia
del freeze script).
Smoke E2E manual: runtime/python/bin/python3 ejecuta web_search
con cwd /tmp y registry_root pasado en ctx, sin tocar el .venv del
registry.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -207,17 +207,38 @@ y `jobs.cpp`.
|
||||
|
||||
Implementado en commit `fce3f97` (rama `issue/0033a-multilang-dispatcher`).
|
||||
|
||||
### Fase B — runtime Python embebido (1-2 sesiones)
|
||||
### Fase B — runtime Python embebido (COMPLETADA)
|
||||
|
||||
1. Escribir `tools/freeze_python_runtime.sh` (Linux + Windows).
|
||||
2. Anadir hook al `/compile` skill: tras compilar el `.exe`, ejecutar
|
||||
el freeze si `python_runtime: true`.
|
||||
3. `python_runtime_path()` en `jobs.cpp`: busca `runtime/python/`
|
||||
junto al exe; fallback a env var → registry venv → PATH.
|
||||
4. Test: arranque limpio de `graph_explorer.exe` con runtime/ junto al
|
||||
exe — invocar enricher Python sin WSL ni venv del registry.
|
||||
5. Documentar en `app.md` y en `cpp_apps.md` la nueva regla:
|
||||
apps con enrichers Python necesitan `python_runtime: true`.
|
||||
1. ✅ `tools/freeze_python_runtime.sh` con dos backends:
|
||||
- Linux: copia `python-build-standalone` (uv) ~87 MB, autocontenido.
|
||||
- Windows: descarga `python-3.X.Y-embed-amd64.zip` oficial,
|
||||
habilita site-packages, instala wheels via `pip install
|
||||
--target` cross-platform.
|
||||
Idempotente via `runtime/.lock` con SHA256 de (PY_VERSION, deps,
|
||||
platform). Lee `python_runtime_deps` del frontmatter de `app.md`
|
||||
(override: env `PY_DEPS=...`).
|
||||
2. ⏳ Hook al `/compile` skill — pendiente, parte del issue 0033e.
|
||||
3. ✅ `cached_python_runtime()` en `jobs.cpp` con cadena de
|
||||
fallback: `<exe_dir>/runtime/python/{python.exe|bin/python3}` →
|
||||
`$FN_PYTHON` → `<registry_root>/python/.venv/bin/python3` →
|
||||
`python3` del PATH. Loggea procedencia (`kind=embedded|env|
|
||||
registry_venv|system`) al iniciar jobs_init.
|
||||
4. ✅ Tests:
|
||||
- `tests/test_python_runtime_resolver.py` — 4 tests verifican
|
||||
fallback con/sin embed, override via FN_PYTHON e idempotencia
|
||||
del freeze script.
|
||||
- Smoke E2E manual: `runtime/python/bin/python3` ejecuta
|
||||
`web_search` en cwd arbitrario, sin pasar por el venv del
|
||||
registry.
|
||||
5. ✅ `app.md` actualizado con `python_runtime: true` y
|
||||
`python_runtime_deps: [requests, certifi, urllib3]`.
|
||||
6. ✅ `.gitignore` creado: ignora `runtime/`, `_vendored/`,
|
||||
`.vendor.lock`, binarios Go de enrichers.
|
||||
|
||||
Implementado en commits `<hash-fase-B>`. Para Windows nativo, el
|
||||
spawn ahora bifurca: si el resolver es `embedded`/`env`/`system`,
|
||||
lanza Python Windows nativo via CreateProcessW; si es `registry_venv`
|
||||
(legacy), sigue el camino `wsl.exe` previo.
|
||||
|
||||
### Fase C — UI hints (0.5 sesion)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user