|
| 1 | +# Publishing to PyPI |
| 2 | + |
| 3 | +This guide explains how to publish the Empathy framework to PyPI. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. PyPI account at https://pypi.org/ |
| 8 | +2. PyPI API token (create at https://pypi.org/manage/account/token/) |
| 9 | +3. Add token to GitHub Secrets as `PYPI_API_TOKEN` |
| 10 | + |
| 11 | +## Automated Publishing (Recommended) |
| 12 | + |
| 13 | +The framework uses GitHub Actions for automated publishing: |
| 14 | + |
| 15 | +1. **Update version** in `pyproject.toml`: |
| 16 | + ```toml |
| 17 | + version = "1.7.0" # Update this |
| 18 | + ``` |
| 19 | + |
| 20 | +2. **Update CHANGELOG.md** with release notes |
| 21 | + |
| 22 | +3. **Create and push a git tag**: |
| 23 | + ```bash |
| 24 | + git tag v1.7.0 |
| 25 | + git push origin v1.7.0 |
| 26 | + ``` |
| 27 | + |
| 28 | +4. **GitHub Actions will automatically**: |
| 29 | + - Run all tests |
| 30 | + - Build the package |
| 31 | + - Create a GitHub release |
| 32 | + - Publish to PyPI (if token is configured) |
| 33 | + |
| 34 | +## Manual Publishing |
| 35 | + |
| 36 | +If you need to publish manually: |
| 37 | + |
| 38 | +### 1. Clean previous builds |
| 39 | +```bash |
| 40 | +rm -rf dist/ build/ *.egg-info |
| 41 | +``` |
| 42 | + |
| 43 | +### 2. Build the package |
| 44 | +```bash |
| 45 | +python -m pip install --upgrade build twine |
| 46 | +python -m build |
| 47 | +``` |
| 48 | + |
| 49 | +This creates two files in `dist/`: |
| 50 | +- `empathy-1.6.0.tar.gz` (source distribution) |
| 51 | +- `empathy-1.6.0-py3-none-any.whl` (wheel distribution) |
| 52 | + |
| 53 | +### 3. Check the package |
| 54 | +```bash |
| 55 | +twine check dist/* |
| 56 | +``` |
| 57 | + |
| 58 | +### 4. Test upload to TestPyPI (optional) |
| 59 | +```bash |
| 60 | +twine upload --repository testpypi dist/* |
| 61 | +``` |
| 62 | + |
| 63 | +Install from TestPyPI to verify: |
| 64 | +```bash |
| 65 | +pip install --index-url https://test.pypi.org/simple/ empathy |
| 66 | +``` |
| 67 | + |
| 68 | +### 5. Upload to PyPI |
| 69 | +```bash |
| 70 | +twine upload dist/* |
| 71 | +``` |
| 72 | + |
| 73 | +You'll be prompted for your PyPI username and password/token. |
| 74 | + |
| 75 | +## Verification |
| 76 | + |
| 77 | +After publishing, verify the package: |
| 78 | + |
| 79 | +1. **Check PyPI page**: https://pypi.org/project/empathy/ |
| 80 | +2. **Install and test**: |
| 81 | + ```bash |
| 82 | + pip install empathy |
| 83 | + python -c "from empathy_os import EmpathyOS; print('Success!')" |
| 84 | + ``` |
| 85 | + |
| 86 | +## Version Numbering |
| 87 | + |
| 88 | +Follow [Semantic Versioning](https://semver.org/): |
| 89 | + |
| 90 | +- **Major** (1.x.x): Breaking changes |
| 91 | +- **Minor** (x.1.x): New features, backward compatible |
| 92 | +- **Patch** (x.x.1): Bug fixes, backward compatible |
| 93 | + |
| 94 | +Examples: |
| 95 | +- `1.6.0` → `1.6.1`: Bug fix |
| 96 | +- `1.6.0` → `1.7.0`: New features |
| 97 | +- `1.6.0` → `2.0.0`: Breaking changes |
| 98 | + |
| 99 | +## Troubleshooting |
| 100 | + |
| 101 | +### "Package already exists" |
| 102 | +- Version already published to PyPI |
| 103 | +- Update version in `pyproject.toml` |
| 104 | +- You cannot overwrite or delete PyPI versions |
| 105 | + |
| 106 | +### "Invalid distribution" |
| 107 | +- Run `twine check dist/*` to see errors |
| 108 | +- Common issues: |
| 109 | + - Missing README.md |
| 110 | + - Invalid pyproject.toml |
| 111 | + - Missing required files in MANIFEST.in |
| 112 | + |
| 113 | +### "Authentication failed" |
| 114 | +- Check your PyPI token/password |
| 115 | +- Tokens must start with `pypi-` |
| 116 | +- Use username `__token__` with API tokens |
| 117 | + |
| 118 | +## Best Practices |
| 119 | + |
| 120 | +1. **Always test locally** before publishing |
| 121 | +2. **Run full test suite**: `pytest` |
| 122 | +3. **Check code quality**: `black . && ruff check .` |
| 123 | +4. **Update documentation** before release |
| 124 | +5. **Tag releases** in git for traceability |
| 125 | +6. **Never publish** with failing tests |
| 126 | + |
| 127 | +## Package Contents |
| 128 | + |
| 129 | +The published package includes: |
| 130 | +- Core framework code (`empathy_os/`, `empathy_llm_toolkit/`) |
| 131 | +- All wizards (`wizards/`, `coach_wizards/`) |
| 132 | +- Plugins (`empathy_healthcare_plugin/`, `empathy_software_plugin/`) |
| 133 | +- Documentation (`README.md`, `LICENSE`, etc.) |
| 134 | +- Configuration files |
| 135 | + |
| 136 | +Excluded from package (see MANIFEST.in): |
| 137 | +- Tests (`tests/`) |
| 138 | +- CI/CD configs (`.github/`) |
| 139 | +- Development files (`.gitignore`, `.pre-commit-config.yaml`) |
| 140 | +- Backend API (`backend/`) |
| 141 | +- Website (`website/`) |
0 commit comments