Publishing WRTKit to PyPI¶
This guide explains how to publish the wrtkit package to PyPI.
Prerequisites¶
Before Publishing¶
-
Update version in
pyproject.toml: -
Update author information in
pyproject.toml: -
Update URLs in
pyproject.toml: -
Run tests:
-
Check code quality:
Building the Package¶
Build the distribution packages:
This creates:
- dist/wrtkit-0.1.0.tar.gz (source distribution)
- dist/wrtkit-0.1.0-py3-none-any.whl (wheel distribution)
Testing on TestPyPI¶
-
Upload to TestPyPI:
-
Test installation from TestPyPI:
-
Test the installed package:
Publishing to PyPI¶
Once you've verified everything works on TestPyPI:
-
Upload to PyPI:
-
Install from PyPI:
Using GitHub Actions for Automated Publishing¶
The repository includes a GitHub Actions workflow that automatically publishes to PyPI when you create a release.
Setup¶
- Create a PyPI API token:
- Go to https://pypi.org/manage/account/token/
- Create a new token with upload permissions
-
Copy the token (it starts with
pypi-) -
Add the token to GitHub Secrets:
- Go to your repository on GitHub
- Settings → Secrets and variables → Actions
- Click "New repository secret"
- Name:
PYPI_API_TOKEN - Value: Your PyPI token
Creating a Release¶
-
Update the version in
pyproject.toml -
Commit and push the changes:
-
Create a git tag:
-
Create a release on GitHub:
- Go to your repository on GitHub
- Click "Releases" → "Create a new release"
- Select the tag you created
- Add release notes
- Click "Publish release"
The GitHub Action will automatically build and publish the package to PyPI.
Versioning¶
Follow Semantic Versioning: - MAJOR version for incompatible API changes - MINOR version for new functionality in a backwards compatible manner - PATCH version for backwards compatible bug fixes
Examples:
- 0.1.0 - Initial release
- 0.1.1 - Bug fix
- 0.2.0 - New features
- 1.0.0 - First stable release
Troubleshooting¶
Authentication Issues¶
If you have trouble authenticating, use API tokens instead of passwords:
File Already Exists Error¶
You cannot upload the same version twice. Increment the version number in pyproject.toml and rebuild.
Import Errors After Installation¶
Make sure the package structure is correct:
And that pyproject.toml has: