worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

Publish worktrunk to PyPI

Open fresh2dev opened this issue 2 weeks ago • 3 comments

Feature Request

Publish the wt binary to PyPI as platform wheels, the way ruff and uv ship theirs.

Why

Python tooling that builds on worktrunk can't declare it as a dependency today. Users have to install wt separately with Homebrew, Cargo or the installer script, and the tooling can't pin a version.

A PyPI package would allow three things:

  • Bootstrap with no install step. uvx --from worktrunk wt list works on any machine with uv, including CI runners and fresh dev containers.

  • Bundle it as a dependency. A Python CLI adds worktrunk>=0.82 to pyproject.toml, and wt lands in the same environment, version-locked in uv.lock.

  • Write self-contained scripts. A PEP 723 script declares worktrunk inline and runs with uv run:

    # /// script
    # dependencies = ["worktrunk"]
    # ///
    import json, subprocess
    
    out = subprocess.run(
        ["wt", "list", "--format=json"],
        capture_output=True, text=True, check=True,
    ).stdout
    for worktree in json.loads(out)["items"]:
        ...
    

Suggested approach

Use maturin with bindings = "bin". It packs the existing Rust binary into wheels with no Python code and no changes to the crate.

  • Add a small pyproject.toml that points maturin at the existing crate.
  • Add a release job (maturin-action) that builds wheels for the five targets the release already covers, then publishes with PyPI trusted publishing, so there is no token to manage.
  • The name worktrunk is currently unclaimed on PyPI.

Out of scope

A Python API. The binary on PATH plus --format=json is enough.

fresh2dev avatar Nov 16 '26 09:11 fresh2dev

Adding a PyPI channel is a maintainer call. Some details of the current release pipeline affect how it would fit in:

  • Reuse the release binaries; don't rebuild them. release.yaml builds the five targets once with cargo-dist. It then sends the Windows archive through SignPath and swaps the signed wt.exe back in before anything publishes. A separate maturin-action build would compile its own copy, so the Windows wheel would ship an unsigned binary that differs from the one on GitHub Releases, winget and Homebrew. A PyPI job that repackages the signed archives from the host job into wheels would keep every channel on the same bytes.
  • Windows wt naming. On Windows, wt collides with Windows Terminal, so winget installs Worktrunk as git-wt as well (see the README). The release builds turn on the git-wt feature, so a wheel could carry both binaries. A script that runs wt on Windows would still reach whichever wt comes first on PATH.
  • One more publish job. PyPI would join crates.io, winget, Homebrew and AUR in the jobs that announce waits on, so a PyPI outage could hold up the release announcement unless the job is allowed to fail.

There's a partial option today: the community conda-forge feedstock lets Pixi or conda environments declare and lock worktrunk. That doesn't help uvx, uv.lock or PEP 723 scripts, which is the gap this request covers.

worktrunk-bot avatar Nov 16 '26 09:11 worktrunk-bot

let's draft this @worktrunk-bot , it's a good idea!

max-sixty avatar Nov 16 '26 10:11 max-sixty

Drafted in #4823. It repackages the release archives into wheels rather than rebuilding, so PyPI gets the same binaries as the other channels. Before the next release, it needs a pending trusted publisher on PyPI for worktrunk, scoped to release.yaml and the release environment. The PR body has the exact fields.

worktrunk-bot avatar Nov 16 '26 10:11 worktrunk-bot