Skip to content

Lesson 9 of 9 · 23m

Distribution, Releases, and Upgrade Compatibility

Publish releases operators can trust, automate artifacts, handle breaking CLI changes, and support users after the binary leaves your machine.

Shipping a CLI is a long-term compatibility commitment. The first release is easy; the fifth release is when someone has pinned your tool in a deployment pipeline, wrapped it in shell scripts, and built muscle memory around its prompts. Distribution work is mostly reducing surprise.

PyPI is the normal path for pipx tools

python -m build
python -m twine check dist/*
python -m twine upload dist/*

Use a trusted publisher or scoped API token rather than a password in CI. Tag the release in git and make the artifact reproducible from that tag. If someone cannot connect a wheel on PyPI to source history, incident response becomes guesswork.

Automate release checks before upload

A release pipeline should at minimum:

run tests
build wheel and sdist
install the wheel into a clean virtual environment
run --version and one smoke command
upload only after those pass

That clean-install smoke test catches missing package data and undeclared dependencies better than another hundred unit tests.

Breaking changes need migration paths

Changing --format=json to --json is trivial in source and expensive for users. Better options:

  • accept both spellings for one or more releases
  • warn on deprecated spelling before removing it
  • version machine-readable output explicitly
  • document exact migration commands in the changelog

Semantic versioning is a useful communication device, but only if you actually treat the CLI surface as the versioned interface: command names, flags, exit codes, stdout formats, and config keys all count.

Not every tool should be a PyPI-only artifact

Sometimes users cannot install Python tooling in the target environment. Options include zipapps (.pyz), container images, or frozen binaries built with PyInstaller. Each has tradeoffs:

pipx:       best for Python-capable users, small artifacts, easy upgrades
zipapp:     one file, still requires a compatible Python interpreter
container:  consistent runtime, awkward file/network ergonomics
frozen exe: no Python required, larger artifact and more platform support burden

Choose based on user environment, not fashion. Internal infrastructure tools often thrive as pipx packages; incident-response tools may need a single static-ish artifact.

Build observability into support

--version, doctor, verbose logging, redacted effective config, and clear error codes save more support time than clever code. When a user reports failure, you want to ask for one command output, not conduct a scavenger hunt.

Field notes

  • Never overwrite a published release artifact. Yank or publish a patch release; mutated release history destroys trust.
  • Shell completions are valuable, but treat them as generated artifacts and test installation instructions for bash, zsh, and fish separately.
  • Pre-release versions (1.5.0rc1) are useful only if your users know pipx requires --pip-args or explicit versions in some workflows; document exact commands.
  • Keep upgrade notes operational: say what command output changes and what automation must change, not merely “improved CLI behavior.”

Was this lesson helpful?

Sign in to rate