feat(cli): add py script type & Python interpreter resolution (#3278)#27
Closed
mnriem wants to merge 1 commit into
Closed
feat(cli): add py script type & Python interpreter resolution (#3278)#27mnriem wants to merge 1 commit into
py script type & Python interpreter resolution (#3278)#27mnriem wants to merge 1 commit into
Conversation
…ub#3278) Introduce a third script variant alongside `sh`/`ps` as the foundation for unifying workflow scripts under a single Python implementation. - Add `"py": "Python"` to `SCRIPT_TYPE_CHOICES`; `VALID_SCRIPT_TYPES` consumers (init workflow step, init command, _helpers) pick it up automatically since they derive from that mapping. - Add `IntegrationBase.resolve_python_interpreter()` (project venv → `python3` → `python`, falling back to `python3`). - Prefix the resolved interpreter when `process_template()` expands `{SCRIPT}` for the `py` script type so `.py` scripts run portably (notably on Windows); thread `project_root` through callers so venv preference works. - Make `install_scripts()` mark copied `.py` files executable too. Includes positive and negative unit tests for interpreter resolution, `py` template processing, the new choice, and script installation. Assisted-by: GitHub Copilot (model: Claude Opus 4.8, autonomous) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
Implements github#3278 — the foundation step toward unifying workflow scripts under a single Python implementation per command (github#3277). Adds a third script variant (
py) alongsidesh/ps.Changes
"py": "Python"toSCRIPT_TYPE_CHOICESin_agent_config.py. AllVALID_SCRIPT_TYPESconsumers (the init workflow step,commands/init.py, andintegrations/_helpers.py) derive from this mapping, so they acceptpywithout further change.process_template()(integrations/base.py): Confirmed the existing genericscript_typelogic extractspy:from frontmatter unchanged. When the script type ispy, the{SCRIPT}expansion is now prefixed with a resolved Python interpreter so.pyscripts run portably (notably on Windows, where.pyfiles aren't directly executable).IntegrationBase.resolve_python_interpreter()helper — prefers a project venv (.venv/bin/pythonor.venv/Scripts/python.exe), thenpython3, thenpython, falling back topython3.project_rootis threaded through theprocess_template()callers so the venv preference works.install_scripts(): Copied.pyfiles are now marked executable (previously.sh-only).Out of scope
Adding
py:lines to the templates'scripts:frontmatter is tracked separately in github#3283. Until then,{SCRIPT}is left literal forpy(existing graceful fallback when no matching frontmatter line exists).Tests
Added positive and negative unit tests:
python3, falls back topython, falls back topython3when nothing is found, prefers POSIX/Windows venv, ignores a missing venv.process_templatewithpy: prefixes interpreter + rewrites path;shis not prefixed; venv is used whenproject_rootis passed.install_scripts:.py/.shmade executable, non-script file is not.SCRIPT_TYPE_CHOICES/VALID_SCRIPT_TYPES; unknown variant rejected.Verification
specify init x --script pycompletes without error and records"script": "py".ruff checkclean on changed files.🤖 This PR was authored autonomously by GitHub Copilot (model: Claude Opus 4.8) on behalf of @mnriem.