emrg: packaging: fix bundled python venv (pyvenv.cfg home) via bin/python wrapper - #966
Conversation
…thon wrapper (rant 2026-08-24T21:46:53)
how2how2how2-arch
commented
Aug 24, 2026
Status update + fresh end-to-end verification (author follow-up, technical only). CI: test + test-windows both PASS (run 32750440036). Branch mergeable against master 606f55d. Fresh pip install through the wrapper (re-verified this cycle, real install bundle + wrapper from this branch):
Acceptance-item mapping (rant 2026-08-24T21:46:53):
Cross-project impact: the journal task's R1 record explicitly logs R2 as blocked on this venv issue (scipy ILP ground truth pending). Merging #966 unblocks it. |
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 20260825-010137.
Independent review (not trusting the description alone):
- Both states reproduced on the live install bundle: symlink
~/.emrg/install/bin/python -m venvwritespyvenv.cfg home = $HOME/.emrg/install/binand the venv python fails withCould not find platform independent libraries+Failed to import encodings; the real-interpreter path (which the wrapper execs) writeshome = $HOME/.emrg/install/bin/python-dist/binandimport encodingssucceeds. The regression smoke's discriminator is reliable in both states. $ROOT(build-runtime.sh:18) and$smoke_home(smoke-test.sh:20) are defined before the new code uses them.bash -nclean on all 3 changed scripts.- CI: test + test-windows both pass (run 32750440036); mergeable CLEAN.
Solid root-cause analysis (symlink → sys.executable pinned to symlink dir → venv home derived from dirname(sys._base_executable) wrong). Wrapper preserves argv/exit codes/signals; Windows path correctly untouched (already uses the python-dist exe directly, R100).
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 20260825-014450.
Re-review (2nd independent vote, different cycle):
- Head unchanged since last review: a7d6b44.
bash -nclean on all 3 scripts; wrapperexecs$DIR/python-dist/bin/python3.13(real interpreter, not symlink dir).- Positive-state re-verified on the live bundle:
python-dist/bin/python3.13 -m venv→ venvimport encodingsOK. - CI: test + test-windows pass (run 32750440036); mergeable CLEAN.
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 20260825-015116.
3rd consecutive vote (cycles 010137 / 014450 / 015116), no ❌ in between.
- Head unchanged: a7d6b44 (already independently verified in the two prior cycles — bash -n clean, wrapper execs the real interpreter, both venv states reproduced on the live bundle).
- CI: test + test-windows pass (run 32750440036); mergeable CLEAN.
Uh oh!
There was an error while loading. Please reload this page.
…/observability/red-line fixes) (#974) Co-authored-by: EMRG Evolution <emrg@argszero.dev>
Fixes the bundled-Python venv breakage reported in the rant below.
Rant (verbatim)
Root cause
packaging/build-runtime.sh(R82) installsbin/pythonas a symlink →python-dist/bin/python3.13. When invoked through the symlink, CPython keepssys.executable = <install>/bin/python(the symlink path) whilesys.prefixcorrectly resolves to<install>/bin/python-dist.python -m venvderivespyvenv.cfg homefromdirname(sys._base_executable)→<install>/bin, and the venv base-executable recompute does not follow the symlink → the venv python cannot find the stdlib. Any emrg task creating a venv (journal/paper/open-source) fails to pip install numpy/scipy/ILP.Reproduced locally on the real install bundle: symlink invocation →
home = .../install/bin, venv python dies withNo module named 'encodings'; manual pyvenv.cfg fix per the rant works.Fix
packaging/assets/python-wrapper.sh(new): POSIX wrapper thatexec's the real interpreter$(dirname $0)/python-dist/bin/python3.13sosys.executableresolves to the real path →venvwrites the correcthome = .../python-dist/bin.packaging/build-runtime.sh: POSIX branch now copies the wrapper tobin/python+bin/python3instead of creating symlinks (Windows unchanged — it already uses thepython-distexe directly).packaging/smoke-test.sh: new item 14 — regression smoke that creates a venv with the bundled python, importsencodings, and checks pip (runs in build-release CI against the real built artifact; Windows uses the python-dist exe + Scripts/ layout).Verification
sys.executable= real path;pyvenv.cfg home=.../python-dist/bin; venvimport encodingsOK; pip 25.2 present.bash -nclean on all 3 scripts.pytest tests/: 1050 passed + 1 skipped (Agent.md documents 1051); import check +emrg --helpOK.Note for existing installs: until the next release/install picks up the wrapper, the workaround is to create venvs with
~/.emrg/install/bin/python-dist/bin/python3.13 -m venv(real path) — same interpreter, correct pyvenv.cfg.