|
| 1 | +# Build and Publish Guide |
| 2 | + |
| 3 | +This guide explains how to build and publish the ProactiveAgent library to PyPI using `uv`. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- `uv` package manager installed |
| 8 | +- PyPI account and API token |
| 9 | +- TestPyPI account (recommended for testing) |
| 10 | + |
| 11 | +## Version Management |
| 12 | + |
| 13 | +### Update Library Version |
| 14 | + |
| 15 | +Update the version of your library in `pyproject.toml`: |
| 16 | + |
| 17 | +```bash |
| 18 | +# Patch version (0.1.0 → 0.1.1) - for bug fixes |
| 19 | +uv version patch |
| 20 | + |
| 21 | +# Minor version (0.1.0 → 0.2.0) - for new features |
| 22 | +uv version minor |
| 23 | + |
| 24 | +# Major version (0.1.0 → 1.0.0) - for breaking changes |
| 25 | +uv version major |
| 26 | + |
| 27 | +# Set specific version |
| 28 | +uv version 0.2.0 |
| 29 | +``` |
| 30 | + |
| 31 | +## Build Process |
| 32 | + |
| 33 | +### 1. Build the Package |
| 34 | + |
| 35 | +Create distribution files (wheel and source distribution): |
| 36 | + |
| 37 | +```bash |
| 38 | +uv build |
| 39 | +``` |
| 40 | + |
| 41 | +This creates `.whl` and `.tar.gz` files in the `dist/` directory. |
| 42 | + |
| 43 | +### 2. Verify Build |
| 44 | + |
| 45 | +Check what will be included in your package: |
| 46 | + |
| 47 | +```bash |
| 48 | +# View built files |
| 49 | +ls -la dist/ |
| 50 | + |
| 51 | +# Check package contents (if twine is available) |
| 52 | +twine check dist/* |
| 53 | +``` |
| 54 | + |
| 55 | +## Publishing Process |
| 56 | + |
| 57 | +### 1. Test on TestPyPI (Recommended) |
| 58 | + |
| 59 | +First, test your package on TestPyPI: |
| 60 | + |
| 61 | +```bash |
| 62 | +uv publish --index testpypi |
| 63 | +``` |
| 64 | + |
| 65 | +### 2. Test Installation from TestPyPI |
| 66 | + |
| 67 | +Verify your package works correctly: |
| 68 | + |
| 69 | +```bash |
| 70 | +# Install from TestPyPI |
| 71 | +pip install --index-url https://test.pypi.org/simple/ proactiveagent |
| 72 | + |
| 73 | +# Test the installation |
| 74 | +python -c "import proactiveagent; print('Installation successful!')" |
| 75 | +``` |
| 76 | + |
| 77 | +### 3. Publish to Main PyPI |
| 78 | + |
| 79 | +Once tested, publish to the main PyPI: |
| 80 | + |
| 81 | +```bash |
| 82 | +uv publish |
| 83 | +``` |
| 84 | + |
| 85 | +## Complete Workflow |
| 86 | + |
| 87 | +Here's the recommended complete workflow: |
| 88 | + |
| 89 | +```bash |
| 90 | +# 1. Update version |
| 91 | +uv version minor |
| 92 | + |
| 93 | +# 2. Build package |
| 94 | +uv build |
| 95 | + |
| 96 | +# 5. If successful, publish to main PyPI |
| 97 | +uv publish |
| 98 | +``` |
| 99 | + |
| 100 | +## Configuration |
| 101 | + |
| 102 | +The project is already configured with: |
| 103 | +- Proper package metadata and classifiers |
| 104 | +- Build system using `hatchling` |
| 105 | + |
| 106 | +## Troubleshooting |
| 107 | + |
| 108 | +### Common Issues |
| 109 | + |
| 110 | +1. **Authentication errors**: Ensure your API tokens are correct and have proper permissions |
| 111 | +2. **Version conflicts**: Make sure the version doesn't already exist on PyPI |
| 112 | +3. **Build errors**: Check that all required files are included in the package |
| 113 | + |
| 114 | +### Check Package Contents |
| 115 | + |
| 116 | +```bash |
| 117 | +# See what files will be included |
| 118 | +uv build --sdist --wheel |
| 119 | +tar -tzf dist/proactiveagent-*.tar.gz | head -20 |
| 120 | +``` |
| 121 | + |
| 122 | +### Validate Before Publishing |
| 123 | + |
| 124 | +```bash |
| 125 | +# Check for common issues |
| 126 | +python -m build --check |
| 127 | +``` |
| 128 | + |
| 129 | +## Post-Publication |
| 130 | + |
| 131 | +After successful publication: |
| 132 | + |
| 133 | +1. Verify the package is available on PyPI |
| 134 | +2. Test installation: `pip install proactiveagent` |
| 135 | +3. Update documentation if needed |
| 136 | +4. Create a GitHub release with the same version tag |
| 137 | + |
| 138 | +## Useful Commands |
| 139 | + |
| 140 | +```bash |
| 141 | +# Check outdated dependencies |
| 142 | +uv tree --outdated |
| 143 | + |
| 144 | +# Upgrade dependencies |
| 145 | +uv sync --upgrade |
| 146 | + |
| 147 | +# Clean build artifacts |
| 148 | +rm -rf dist/ build/ *.egg-info/ |
| 149 | + |
| 150 | +# View package info |
| 151 | +uv tree |
| 152 | +``` |
0 commit comments