Skip to content

feat(scripts): add Python check-prerequisites PoC#3302

Open
WOLIKIMCHENG wants to merge 1 commit into
github:mainfrom
WOLIKIMCHENG:feat-python-check-prerequisites-poc
Open

feat(scripts): add Python check-prerequisites PoC#3302
WOLIKIMCHENG wants to merge 1 commit into
github:mainfrom
WOLIKIMCHENG:feat-python-check-prerequisites-poc

Conversation

@WOLIKIMCHENG

Copy link
Copy Markdown
Contributor

Description

Adds a Python proof-of-concept implementation for check-prerequisites as part of #3279.

Scope:

  • adds scripts/python/common.py with the helper subset needed by this script
  • adds scripts/python/check_prerequisites.py
  • adds parity tests against the existing Bash and PowerShell behavior
  • does not switch command templates or runtime usage to Python

This 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 -q
  • uvx ruff check scripts/python tests/test_check_prerequisites_python_parity.py
  • git diff --check

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py with Python equivalents of the subset of shared helpers needed for prerequisite/path resolution.
  • Added scripts/python/check_prerequisites.py implementing check-prerequisites flag behavior in Python.
  • Added tests/test_check_prerequisites_python_parity.py to 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

Comment thread scripts/python/common.py
Comment on lines +67 to +70
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()
Comment on lines +179 to +183
for flag in [
"--json",
"--require-tasks",
"--include-tasks",
"--paths-only",
Comment on lines +201 to +205
@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")

@mnriem mnriem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address Copilot feedback

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.

PoC: port check-prerequisites to Python with output-parity tests

3 participants