Skip to content

fix: auto-detect PYTHONHOME and catch panics in embedded Python#16

Merged
dipankar merged 1 commit into
mainfrom
fix/clean-pythonhome
May 8, 2026
Merged

fix: auto-detect PYTHONHOME and catch panics in embedded Python#16
dipankar merged 1 commit into
mainfrom
fix/clean-pythonhome

Conversation

@dipankar

@dipankar dipankar commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes Embedded Python in daemon requires PYTHONHOME to find stdlib #4
  • The daemon's embedded Python (pyo3) failed with ModuleNotFoundError: No module named 'encodings' when PYTHONHOME was not set
  • Added ensure_pythonhome() in embedded.rs that auto-detects the Python prefix from VIRTUAL_ENV or python3 -c "import sys; print(sys.base_prefix)"
  • Wrapped is_available() in catch_unwind so a fatal Python init error crashes only the embedded probe, not the entire daemon

Test plan

  • Build daemon: cargo build --release -p rpytest-daemon
  • Unset PYTHONHOME, start daemon — should auto-detect and work
  • Run rpytest tests/ -q — all tests should pass

The daemon's embedded Python (pyo3) failed with ModuleNotFoundError for
encodings when PYTHONHOME was not set.

- Added ensure_pythonhome() that auto-detects prefix from VIRTUAL_ENV or
  system python3 before any PyO3 initialization.
- Wrapped is_available() in catch_unwind so a bad Python init crashes
  only the embedded probe, not the entire daemon.

Fixes #4
@dipankar dipankar merged commit 3dc0854 into main May 8, 2026
2 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embedded Python in daemon requires PYTHONHOME to find stdlib

1 participant