This guide explains how to publish PyInterpret so anyone can install it with pip install pyinterpret.
-
PyPI Account: Create accounts on both:
-
API Tokens: Generate API tokens for upload authentication:
- Go to Account Settings → API tokens
- Create tokens for both Test PyPI and PyPI
- Save these tokens securely
Use the automated publisher script:
python publish_package.pyThis script will:
- Clean old build files
- Install required tools
- Build the package
- Check for errors
- Upload to Test PyPI (optional)
- Upload to real PyPI
If you prefer manual control:
pip install build twinerm -rf build dist *.egg-infopython -m buildpython -m twine check dist/*python -m twine upload --repository testpypi dist/*Test installation:
pip install -i https://test.pypi.org/simple/ pyinterpretpython -m twine upload dist/*Once published, anyone can install PyInterpret:
# Basic installation
pip install pyinterpret
# With optional dependencies
pip install pyinterpret[shap] # SHAP support
pip install pyinterpret[lime] # LIME support
pip install pyinterpret[all] # All featuresWhen uploading, you'll be prompted for credentials. Use:
- Username:
__token__ - Password: Your API token (starts with
pypi-)
To release a new version:
-
Update version in
pyinterpret/__init__.py:__version__ = "0.1.1" # Increment version
-
Update version in
pyproject.toml:version = "0.1.1"
-
Follow publishing steps again
Before publishing, ensure:
- All tests pass:
python -m pytest tests/ - Examples work:
python examples/basic_usage.py - Documentation is updated
- Version numbers match in all files
- README.md has installation instructions
- LICENSE file exists
- All dependencies are correctly specified
After publishing:
- Check PyPI page for your package
- Monitor download statistics
- Watch for user feedback and issues
Common Issues:
-
"Package already exists": You cannot overwrite a version. Increment the version number.
-
Authentication failed: Double-check your API token and ensure you're using
__token__as username. -
Build errors: Check that all files are included in
MANIFEST.in. -
Import errors: Test the package in a fresh environment after installation.
For automated publishing (advanced):
- Set up GitHub Actions
- Use trusted publishing with PyPI
- Automate version bumping and releases
If you encounter issues:
- Check the PyPI Help
- Review build logs for specific errors
- Test in a clean virtual environment
- Verify package structure matches Python standards