fix(win): SoniTranslate venv paths cross-platform — Scripts/ on Windows (#186) - #188
Conversation
…ws (#186) sonitranslate.py hardcoded SONI_VENV/'bin'/{pip,python} (POSIX). On Windows, python -m venv creates Scripts\ with .exe, so is_venv_ready() was always False (install looped) and start() fell back to the wrong interpreter -> 30s timeout. - Add _venv_bin(name): Scripts/{name}.exe on win32 else bin/{name} (mirrors engines/indextts/bootstrap.py). Use it for the is_venv_ready/install/start pip+python paths. - stop(): _proc.terminate() instead of send_signal(SIGTERM) (cross-platform); drop the now-unused signal import. - test: _venv_bin returns Scripts/pip.exe on win32, bin/python on posix. Closes #186. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR fixes SoniTranslate venv path resolution to work on Windows. It introduces a ChangesSoniTranslate Windows Venv and Subprocess Compatibility
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| backend/services/sonitranslate.py | Adds _venv_bin() cross-platform helper and wires it into is_venv_ready/install/start; replaces send_signal(SIGTERM) with terminate(); drops signal import. Logic is correct and minimal. |
| tests/test_sonitranslate_venv.py | New test file covering both platform branches of _venv_bin via monkeypatch; assertions are correct and sufficient for the change. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[is_venv_ready / install / start] --> B{_venv_bin name}
B -->|sys.platform == win32| C[SONI_VENV / Scripts / name.exe]
B -->|POSIX / macOS / Linux| D[SONI_VENV / bin / name]
C --> E[pip.is_file / spawn pip install / Popen python]
D --> E
F[stop] --> G[_proc.terminate]
G -->|cross-platform| H{timeout 5s}
H -->|ok| I[_proc = None]
H -->|TimeoutExpired| J[_proc.kill] --> I
Reviews (1): Last reviewed commit: "fix(win): SoniTranslate venv paths cross..." | Re-trigger Greptile
| _proc: Optional[subprocess.Popen] = None | ||
|
|
||
|
|
||
| def _venv_bin(name: str): |
There was a problem hiding this comment.
Missing return type annotation on
_venv_bin. Every other function in this module is annotated, and the indextts _venv_python_path reference this mirrors also carries a -> Path annotation. Adding it keeps the file consistent and makes IDE type-checking fully effective for callers.
| def _venv_bin(name: str): | |
| def _venv_bin(name: str) -> Path: |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Closes #186.
Bug:
sonitranslate.pyhardcodedSONI_VENV/"bin"/{pip,python}(POSIX). On Windows,python -m venvcreatesScripts\(with.exe), sois_venv_ready()was alwaysFalse(install loops), andstart()fell back to the app's own interpreter → SoniTranslate never came up →RuntimeError("…failed to start within 30s").Fix: add
_venv_bin(name)→Scripts/{name}.exeon win32 elsebin/{name}(mirrors the existingengines/indextts/bootstrap.pypattern); use it for theis_venv_ready/install/startpip+python paths. Alsostop()now uses_proc.terminate()(cross-platform) instead ofsend_signal(SIGTERM), and drops the now-unusedsignalimport.Test:
_venv_binreturnsScripts/pip.exeon win32 andbin/pythonon posix. Router smoke confirms the app still boots.(Opt-in/experimental engine — Windows-only impact — but now functional there.)
🤖 Generated with Claude Code
Summary by CodeRabbit
Improvements
Tests