Publishing to PyPI¶
Overview¶
This document covers the process of publishing enveloper to PyPI and TestPyPI.
Prerequisites¶
twineinstalled:pip install twine- PyPI account with 2FA enabled
- API token for PyPI
- API token for TestPyPI (optional)
Configuration¶
Create ~/.pypirc¶
[pypi]
username = __token__
password = pypi-...
[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = pypi-...
Get API Tokens¶
Using Make¶
Publish to TestPyPI¶
This command: 1. Bumps the patch version 2. Builds the package 3. Uploads to TestPyPI
Publish to PyPI¶
This command: 1. Builds the package 2. Uploads to PyPI
Manual Publishing¶
Build the Package¶
Upload to TestPyPI¶
Upload to PyPI¶
GitHub Actions (Optional)¶
The repo includes a workflow that publishes only on version tags or when you run it manually.
Setup¶
- Configure trusted publishing on PyPI and TestPyPI
- Create GitHub Environments
pypiandtestpypi - See the comments in
.github/workflows/publish.yml
Usage¶
- Push a tag like
v0.1.9(matchingversioninpyproject.toml) - Or use Actions → Publish to PyPI → Run workflow and choose PyPI or TestPyPI
Versioning¶
Versions are managed in pyproject.toml:
The make publish-test command automatically bumps the patch version.
Verification¶
TestPyPI¶
# Install from TestPyPI
pip install -i https://test.pypi.org/simple/ enveloper
# Verify installation
enveloper --version
PyPI¶
Troubleshooting¶
Authentication Failed¶
# Check ~/.pypirc
cat ~/.pypirc
# Verify token is valid
curl -u __token__:pypi-... https://upload.pypi.org/legacy/
File Already Exists¶
Build Errors¶
Upload Errors¶
```bash
Check file permissions¶
ls -la dist/
Verify file integrity¶
twine check dist/*