Skip to content

fix(packaging): bundle scripts/python into the wheel core_pack (#3665)#3670

Merged
mnriem merged 1 commit into
github:mainfrom
martincham:fix/3665-bundle-python-scripts-core-pack
Jul 22, 2026
Merged

fix(packaging): bundle scripts/python into the wheel core_pack (#3665)#3670
mnriem merged 1 commit into
github:mainfrom
martincham:fix/3665-bundle-python-scripts-core-pack

Conversation

@martincham

Copy link
Copy Markdown
Contributor

Fixes #3665.

Problem

specify init --script py generates command/skill files that invoke python3 .specify/scripts/python/<name>.py, but the released wheel never contained those scripts, so --script py is non-functional on every install channel (PyPI, Homebrew). --script sh and --script ps are unaffected.

Root cause

The wheel's force-include list in pyproject.toml carried only scripts/bash and scripts/powershell into specify_cli/core_pack/. The installer resolves --script py to the variant dirs ("python", <platform shell>) and copies whatever variant directories exist in the bundle (shared_infra.py), so from a wheel the python/ variant was silently absent.

Neither Python-scripts PR (#3302 PoC, #3386 port) touched pyproject.toml — the port wired up shared_infra.py, the skill placeholder resolver, the command templates and ~1,800 lines of parity tests, but the packaging manifest was missed. Python scripts under extensions/* ship correctly only because those extensions are force-included as whole directories.

Why CI didn't catch it

Every test runs from a source checkout, where _locate_core_pack() returns None and the repo-root scripts/ fallback resolves scripts/python/ normally. The parity and integration suites therefore pass against files the wheel does not contain, and nothing in CI built a wheel and inspected its contents.

Fix

  • pyproject.toml: force-include scripts/python alongside the other two variants.
  • tests/contract/test_wheel_core_pack_scripts.py: new contract test that enumerates scripts/* in the repo and asserts each variant is force-included, plus an explicit [Bug]: --script py is broken — core scripts/python/*.py missing from the packaged wheel (core_pack) #3665 regression guard. It asserts against pyproject.toml rather than the filesystem, so it holds regardless of checkout vs. wheel — and a future fourth variant cannot be dropped the same way.

Verification

  • Built the wheel: all five core_pack/scripts/python/*.py present, no __pycache__ leakage.
  • Installed that wheel into a clean venv and ran specify init proj --script py --integration claude. .specify/scripts/python/ now lands with all five files, and every script path referenced by the generated skills exists on disk.
  • Executed the installed scripts in that project: create_new_feature.py --json and check_prerequisites.py --json --paths-only both return the expected JSON contract.
  • Confirmed both new tests fail with the pyproject.toml line reverted.
  • Full suite: 4992 passed, 155 skipped.

Note for reviewers

--script py also installs the platform shell variant alongside python/ (shared_infra.py), which is deliberate — the bundled agent-context and git extension command templates still hard-code shell invocations, as documented in the "Script Types and Migration" section of AGENTS.md. This PR does not change that behavior; a py project still receives bash/ (or powershell/) in addition to python/.

…b#3665)

`specify init --script py` generated skills that invoke
`python3 .specify/scripts/python/<name>.py`, but the wheel's
force-include list only carried `scripts/bash` and `scripts/powershell`.
Installs from PyPI/Homebrew therefore shipped commands pointing at files
that were never packaged, leaving `--script py` non-functional while
`sh`/`ps` kept working.

Force-include `scripts/python` alongside the other two variants, and add
a contract test that asserts every script variant present in the repo is
bundled, so a future variant cannot be dropped the same way.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

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

Bundles Python workflow scripts into wheel installations, fixing --script py.

Changes:

  • Adds scripts/python to wheel packaging.
  • Adds contract tests covering all script variants and #3665.
Show a summary per file
File Description
pyproject.toml Includes Python scripts in core_pack.
tests/contract/test_wheel_core_pack_scripts.py Guards wheel script packaging.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Medium

@mnriem
mnriem merged commit c0f4cee into github:main Jul 22, 2026
14 checks passed
@mnriem

mnriem commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

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.

[Bug]: --script py is broken — core scripts/python/*.py missing from the packaged wheel (core_pack)

3 participants