Fix Python transforms on Windows (resolve interpreter from PATH candidates) - #116
Merged
Merged
Conversation
The local transform subprocess backend hardcoded `python3` as the Python interpreter. On Windows the python.org installer provides `python` and the `py` launcher but no `python3` on PATH, so every Python transform failed with "interpreter not available" (Errno::ENOENT). INTERPRETERS now lists command candidates per language in priority order, and the backend runs the first one found on PATH via a small cross-platform `which` that honors PATHEXT on Windows and bare names on POSIX. Python resolves `python3` first, then `python`, so existing POSIX setups are unchanged while Windows works out of the box. A missing interpreter still falls back to the first candidate so the "not available" error is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Windows fix shipped python3-then-python candidates, but the python.org installer also registers the `py` launcher and keeps it on PATH even when the optional "Add to PATH" step is skipped. Add `py` as a final candidate so Python transforms resolve in that install too. Move the PATH lookup out of Subprocess into TransformBackend::Which. Resolution is a separate responsibility and was previously reachable only by spawning a real interpreter; on its own it is unit-tested directly. Bump the version to 0.8.10 to match the CHANGELOG entry for this fix.
|
👋 Thanks for contributing, @vadimitri! TRMNL operates a Creator Fund that pays a revenue share to OSS contributors. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Serverless transforms fail on Windows whenever the transform is Python (
src/transform.py).Subprocesshardcodes the interpreter command aspython3:The python.org Windows installer provides
python.exeand thepylauncher but nopython3on PATH (only the Microsoft Store build registers apython3alias). SoOpen3.popen3('python3', ...)raisesErrno::ENOENT, which surfaces to the user as "interpreter not available", and there's no config to point it atpython.Fix
Make each language's interpreter a list of command candidates in priority order, and run the first one found on PATH:
Resolution uses a small cross-platform
whichthat honorsPATHEXTon Windows (.EXE/.BAT/…) and bare names on POSIX. Behavior is unchanged on macOS/Linux (python3still wins); Windows now falls back topython. A genuinely missing interpreter falls back to the first candidate, so the existing "interpreter not available" error path is preserved.No new dependencies, no config knobs — transforms just work across platforms.
Tests
cmds:shape.bundle exec rspec spec/lib/trmnlp/transform_backend/subprocess_spec.rbpasses (the unrelatedphpexample needs php installed locally);rubocopclean on both files.