feat(scripts): add Python check-prerequisites PoC#3302
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a Python proof-of-concept implementation of the existing check-prerequisites script, along with a minimal Python common.py helper module and new tests intended to validate output parity against the existing Bash/PowerShell implementations (without switching any runtime templates over to Python yet).
Changes:
- Added
scripts/python/common.pywith Python equivalents of the subset of shared helpers needed for prerequisite/path resolution. - Added
scripts/python/check_prerequisites.pyimplementingcheck-prerequisitesflag behavior in Python. - Added
tests/test_check_prerequisites_python_parity.pyto compare Python output against Bash (and partially against PowerShell).
Show a summary per file
| File | Description |
|---|---|
| tests/test_check_prerequisites_python_parity.py | Adds parity-oriented tests comparing Python output with Bash (and a limited PowerShell case). |
| scripts/python/common.py | Introduces shared Python helpers for repo-root and feature-path resolution plus command formatting. |
| scripts/python/check_prerequisites.py | Implements the Python PoC of prerequisite checking and JSON/text/path-only outputs. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 3
- Review effort level: Low
| if script_file is not None: | ||
| # Installed scripts live at .specify/scripts/python/<script>.py. | ||
| return script_file.resolve().parents[3] | ||
| return Path.cwd().resolve() |
| for flag in [ | ||
| "--json", | ||
| "--require-tasks", | ||
| "--include-tasks", | ||
| "--paths-only", |
| @pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available") | ||
| def test_python_json_output_matches_powershell(prereq_repo: Path) -> None: | ||
| feat = prereq_repo / "specs" / "001-my-feature" | ||
| feat.mkdir(parents=True) | ||
| (feat / "plan.md").write_text("# plan\n", encoding="utf-8") |
There was a problem hiding this comment.
Updated the PowerShell parity test parameterization to name each covered case explicitly in pytest output: JSON, IncludeTasks, RequireTasks+IncludeTasks, and PathsOnly.
Validation:
.venv/bin/python -m pytest tests/test_check_prerequisites_python_parity.py -q- 14 passed, 4 skipped
git diff --check- passed
PowerShell is not available in my local environment, so the PowerShell-specific cases were collected but skipped locally.
mnriem
left a comment
There was a problem hiding this comment.
Please address Copilot feedback
|
Addressed the requested feedback:
Validation:
|
Description
Adds a Python proof-of-concept implementation for
check-prerequisitesas part of #3279.Scope:
scripts/python/common.pywith the helper subset needed by this scriptscripts/python/check_prerequisites.pyThis preserves the existing shell scripts and keeps activation for follow-up issues.
Fixes #3279
Testing
.venv/bin/python -m pytest tests/test_check_prerequisites_python_parity.py -q.venv/bin/python -m pytest tests/test_check_prerequisites_paths_only.py -q.venv/bin/python -m pytest tests/test_setup_tasks.py -quvx ruff check scripts/python tests/test_check_prerequisites_python_parity.pygit diff --check