pyrig-pypi Documentation
A pyrig plugin for publishing Python packages to PyPI.
What it does
Drop-in pyrig plugin that wires PyPI into your project:
- Adds a build-and-publish-to-PyPI job to the deploy workflow that runs after a successful release.
- Overrides the python badge with a PyPI badge that generates the pyversions badge and adds an additional badge for the package's version on PyPI.
No configuration required — installing the package as a development dependency is the whole setup. Then regenerate your pyrig configs as usual. The plugin's overrides are picked up automatically.
Installation
uv add --group dev pyrig-pypi
uv run pyrig mkroot
Setup
One-time setup before the first publish:
- Create account at pypi.org
- Create an API token
- Scope: "Entire account" (recommended change to specific project after first publish)
- Click "Add token"
- Copy token immediately (you won't see it again)
- Add token to your repository secrets as
PYPI_TOKEN
After that, the deploy workflow will automatically upload your package to PyPI after every release.
How it works
The plugin subclasses some pyrig base classes:
DeployWorkflowConfigFileto add the PyPI upload step to the deployment workflow.ProgrammingLanguageto replace the python badge with a PyPI pyversions badge.PackageManagerto add the args for publishing to PyPI.PyprojectConfigFileto add PyPI trove classifiers and keywords to the project metadata.
And adds its own tool class:
PackageIndexto wrap PyPI information and add the PyPI version badge.