Publishing to PyPI¶
Automated Publishing (Recommended)¶
The project uses GitHub Actions for automated publishing.
Release Publishing (Production PyPI)¶
-
Create and push a version tag:
-
Create GitHub Release:
- Go to repository > Releases > "Draft a new release"
- Choose the tag you just created
- Add release notes
- Click "Publish release"
-
Automated workflow will:
- Build the package
- Run tests and quality checks
- Publish to PyPI
- Upload distributions to GitHub Release
Manual Trigger (Test PyPI)¶
For testing before production release:
- Go to Actions > "Publish to PyPI" > "Run workflow"
- Select branch (usually
main) - Check "Publish to Test PyPI"
- Click "Run workflow"
Install from Test PyPI:
Manual Publishing¶
If you need to publish manually:
# Clean previous builds
rm -rf dist/ build/ *.egg-info
# Update version in pyproject.toml
# Build
python -m build
# Check
twine check dist/*
# Upload to Test PyPI first
twine upload --repository testpypi dist/*
# Upload to production PyPI
twine upload dist/*
Version Numbering¶
Follow Semantic Versioning:
- Major (1.0.0 > 2.0.0): Breaking changes
- Minor (1.0.0 > 1.1.0): New features, backward compatible
- Patch (1.0.0 > 1.0.1): Bug fixes, backward compatible
Checklist Before Publishing¶
- All tests pass:
invoke test - Code quality checks pass:
invoke quality - Version number updated in
pyproject.toml - CHANGELOG updated with release notes
- README.md is up-to-date
- No sensitive data in repository
- Package builds successfully:
python -m build - Package passes checks:
twine check dist/* - Tested installation from Test PyPI
Troubleshooting¶
"File already exists" Error¶
PyPI doesn't allow re-uploading the same version. Increment the version number.
Build Fails¶
Upload Authentication Fails¶
For manual uploads, generate an API token from PyPI and store in ~/.pypirc.