This guide walks you through deploying BinomoAPI to PyPI (Python Package Index).
- Python 3.8+ installed
- PyPI account: Create accounts at:
- Test PyPI: https://test.pypi.org/account/register/
- Production PyPI: https://pypi.org/account/register/
- API Tokens: Generate API tokens for both Test PyPI and production PyPI
# Install development dependencies
pip install -r requirements-dev.txt
# Deploy to Test PyPI (for testing)
python deploy.py test
# Deploy to Production PyPI (when ready)
python deploy.py prodREM Deploy to Test PyPI
deploy.bat test
REM Deploy to Production PyPI
deploy.bat prodIf you prefer to run commands manually:
# 1. Clean previous builds
rm -rf build/ dist/ *.egg-info/
# 2. Install build tools
pip install build twine
# 3. Build the package
python -m build
# 4. Check the package
python -m twine check dist/*
# 5. Upload to Test PyPI
python -m twine upload --repository testpypi dist/*
# 6. Upload to Production PyPI (when ready)
python -m twine upload dist/*The project uses modern Python packaging standards:
- Main configuration file following PEP 518/621
- Contains all package metadata, dependencies, and build configuration
- Replaces most functionality of setup.py
- Minimal compatibility file for older tools
- Simply calls
setup()with no arguments - All configuration is in pyproject.toml
- Controls which files are included in the distribution
- Includes documentation, data files, and excludes test files
- Runtime dependencies only for the package
- Used in pyproject.toml dependencies section
- Development dependencies for testing, linting, building
- Install with
pip install -r requirements-dev.txt
The project includes automated workflows:
- Runs on every push and pull request
- Tests multiple Python versions (3.8-3.11)
- Runs linting, type checking, and build tests
- Automatically deploys on GitHub releases
- Manual deployment option via workflow dispatch
- Supports both Test PyPI and production PyPI
For automated deployment, add these secrets to your GitHub repository:
- Go to your GitHub repository → Settings → Secrets and variables → Actions
- Add the following secrets:
TEST_PYPI_API_TOKEN: Your Test PyPI API tokenPYPI_API_TOKEN: Your production PyPI API token
-
Update version in pyproject.toml:
[project] version = "2.1.0" # Update this
-
Update version in BinomoAPI/init.py:
__version__ = "2.1.0" # Update this
-
Create a Git tag:
git tag v2.1.0 git push origin v2.1.0
Follow semantic versioning (semver.org):
- MAJOR (2.x.x): Breaking changes
- MINOR (x.1.x): New features, backward compatible
- PATCH (x.x.1): Bug fixes, backward compatible
After uploading to Test PyPI:
# Install from Test PyPI
pip install --index-url https://test.pypi.org/simple/ BinomoAPI
# Test the installation
python -c "import BinomoAPI; print(BinomoAPI.__version__)"After uploading to production:
# Install from PyPI
pip install BinomoAPI
# Test the installation
python -c "import BinomoAPI; print(BinomoAPI.__version__)"-
"File already exists" error:
- You're trying to upload a version that already exists
- Update the version number in pyproject.toml and init.py
-
Authentication errors:
- Check your API tokens
- Make sure you're using the correct repository (testpypi vs pypi)
-
Build errors:
- Run
python -m buildto see detailed error messages - Check that all required files are present
- Run
-
Import errors after installation:
- Check MANIFEST.in to ensure all necessary files are included
- Verify package structure with
pip show -f BinomoAPI
Before deploying, run these commands to validate:
# Check package structure
python -c "import BinomoAPI; print(dir(BinomoAPI))"
# Check dependencies
python -c "import BinomoAPI.api; print('API module imported successfully')"
# Validate metadata
python -m twine check dist/*
# Test build
python -m build- Always test on Test PyPI first before deploying to production
- Use semantic versioning for version numbers
- Keep dependencies minimal in requirements-clean.txt
- Update documentation when adding new features
- Run tests locally before deploying
- Use virtual environments for testing installations
If you encounter issues:
- Check the GitHub Issues
- Review the PyPI documentation: https://packaging.python.org/
- Join our Discord: https://discord.gg/p7YyFqSmAz