Building¶
This guide explains how to build and publish the kalshi-py package.
Prerequisites¶
- Python 3.9 or higher
- uv package manager
- Access to PyPI (for publishing)
Development Build¶
Install Dependencies¶
Build Package¶
This creates both source distribution (sdist) and wheel files in the dist/
directory.
Build Specific Formats¶
Testing the Build¶
Install from Local Build¶
Test Installation¶
import kalshi_py
print(kalshi_py.__version__)
# Test basic functionality
from kalshi_py import Client
client = Client(base_url="https://api.elections.kalshi.com/trade-api/v2")
Publishing¶
Update Version¶
- Update the version in
pyproject.toml
:
- Update the version in
openapi-config.yaml
:
Build and Publish¶
Publishing to Test PyPI¶
Continuous Integration¶
The project uses GitHub Actions for automated builds and testing:
- Build and Test: Runs on every push and pull request
- Publish: Runs on releases to automatically publish to PyPI
Version Management¶
This project follows Semantic Versioning:
- Major version: Breaking changes
- Minor version: New features (backward compatible)
- Patch version: Bug fixes (backward compatible)
Release Process¶
- Update version in
pyproject.toml
andopenapi-config.yaml
- Update changelog (if applicable)
- Create a release on GitHub
- GitHub Actions will automatically build and publish to PyPI
Troubleshooting¶
Build Errors¶
- Missing dependencies: Run
uv sync --group dev
- Version conflicts: Check
pyproject.toml
for correct version - Permission errors: Ensure you have write access to the directory
Publishing Errors¶
- Authentication: Ensure you have PyPI credentials configured
- Version already exists: Increment the version number
- Network issues: Check your internet connection and PyPI status
Testing Issues¶
- Import errors: Ensure the package is installed correctly
- API errors: Check your API credentials and network connection