|
| 1 | +# Publishing Guide |
| 2 | + |
| 3 | +## 1. Install and Setup pyenv with Python 3.12.10 |
| 4 | + |
| 5 | +### Install pyenv |
| 6 | + |
| 7 | +**macOS (Homebrew):** |
| 8 | +```bash |
| 9 | +brew install pyenv |
| 10 | +``` |
| 11 | + |
| 12 | +**Linux:** |
| 13 | +```bash |
| 14 | +curl https://pyenv.run | bash |
| 15 | +``` |
| 16 | + |
| 17 | +Add the following to your shell config (`~/.zshrc` or `~/.bashrc`): |
| 18 | +```bash |
| 19 | +export PYENV_ROOT="$HOME/.pyenv" |
| 20 | +export PATH="$PYENV_ROOT/bin:$PATH" |
| 21 | +eval "$(pyenv init -)" |
| 22 | +``` |
| 23 | + |
| 24 | +Reload your shell: |
| 25 | +```bash |
| 26 | +source ~/.zshrc # or source ~/.bashrc |
| 27 | +``` |
| 28 | + |
| 29 | +### Install Python 3.12.10 |
| 30 | + |
| 31 | +```bash |
| 32 | +pyenv install 3.12.10 |
| 33 | +``` |
| 34 | + |
| 35 | +### Create a Virtual Environment |
| 36 | + |
| 37 | +```bash |
| 38 | +pyenv shell 3.12.10 |
| 39 | +python -m venv .venv |
| 40 | +source .venv/bin/activate |
| 41 | +``` |
| 42 | + |
| 43 | +Confirm the Python version: |
| 44 | +```bash |
| 45 | +python --version |
| 46 | +# Python 3.12.10 |
| 47 | +``` |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## 2. Install Required Packages |
| 52 | + |
| 53 | +With the virtual environment active: |
| 54 | + |
| 55 | +```bash |
| 56 | +pip install --upgrade pip |
| 57 | +pip install build twine |
| 58 | +``` |
| 59 | + |
| 60 | +--- |
| 61 | + |
| 62 | +## 3. Bump the Version |
| 63 | + |
| 64 | +Before every release, update the version in **two places** so they stay in sync. |
| 65 | + |
| 66 | +**`pyproject.toml`:** |
| 67 | +```toml |
| 68 | +[project] |
| 69 | +name = "onefuse" |
| 70 | +version = "2026.2.0" # <-- update this |
| 71 | +``` |
| 72 | + |
| 73 | +**`onefuse/__init__.py`:** |
| 74 | +```python |
| 75 | +__version__ = "2026.2.0" # <-- update this to match |
| 76 | +``` |
| 77 | + |
| 78 | +The version scheme used in this project is `YYYY.MINOR.PATCH` (e.g. `2026.1.0`, `2026.1.1`, `2026.2.0`). |
| 79 | + |
| 80 | +> **Note:** PyPI does not allow re-uploading the same version. Always bump before building. |
| 81 | +
|
| 82 | +--- |
| 83 | + |
| 84 | +## 4. Build and Publish to TestPyPI |
| 85 | + |
| 86 | +Use TestPyPI to verify the package before publishing to the real index. |
| 87 | + |
| 88 | +### Create a TestPyPI Account |
| 89 | + |
| 90 | +1. Register at [https://test.pypi.org](https://test.pypi.org) |
| 91 | +2. Go to **Account Settings → API tokens** |
| 92 | +3. Create a token scoped to **Entire account** |
| 93 | + |
| 94 | +### Store Credentials (optional) |
| 95 | + |
| 96 | +Add the following to `~/.pypirc` to avoid being prompted each time: |
| 97 | +```ini |
| 98 | +[testpypi] |
| 99 | +username = __token__ |
| 100 | +password = pypi-your-testpypi-token-here |
| 101 | +``` |
| 102 | + |
| 103 | +### Build |
| 104 | + |
| 105 | +```bash |
| 106 | +rm -rf dist/ |
| 107 | +python -m build |
| 108 | +``` |
| 109 | + |
| 110 | +### Validate |
| 111 | + |
| 112 | +```bash |
| 113 | +twine check dist/* |
| 114 | +``` |
| 115 | + |
| 116 | +### Upload to TestPyPI |
| 117 | + |
| 118 | +```bash |
| 119 | +twine upload --repository testpypi dist/* |
| 120 | +``` |
| 121 | + |
| 122 | +When prompted: |
| 123 | +- **Username:** `__token__` |
| 124 | +- **Password:** your TestPyPI API token |
| 125 | + |
| 126 | +### Install from TestPyPI |
| 127 | + |
| 128 | +```bash |
| 129 | +pip install --index-url https://test.pypi.org/simple/ onefuse |
| 130 | +``` |
| 131 | + |
| 132 | +Verify the installed version: |
| 133 | +```bash |
| 134 | +python -c "import onefuse; print(onefuse.__version__)" |
| 135 | +``` |
| 136 | + |
| 137 | +--- |
| 138 | + |
| 139 | +## 5. Build and Publish to PyPI |
| 140 | + |
| 141 | +Only proceed here after successfully verifying the package on TestPyPI. |
| 142 | + |
| 143 | +### Create a PyPI Account |
| 144 | + |
| 145 | +1. Register at [https://pypi.org](https://pypi.org) |
| 146 | +2. Go to **Account Settings → API tokens** |
| 147 | +3. Create a token scoped to **Entire account** (or to the `onefuse` project once it exists) |
| 148 | + |
| 149 | +### Store Credentials (optional) |
| 150 | + |
| 151 | +Add the following to `~/.pypirc`: |
| 152 | +```ini |
| 153 | +[pypi] |
| 154 | +username = __token__ |
| 155 | +password = pypi-your-pypi-token-here |
| 156 | +``` |
| 157 | + |
| 158 | +### Build |
| 159 | + |
| 160 | +```bash |
| 161 | +rm -rf dist/ |
| 162 | +python -m build |
| 163 | +``` |
| 164 | + |
| 165 | +### Validate |
| 166 | + |
| 167 | +```bash |
| 168 | +twine check dist/* |
| 169 | +``` |
| 170 | + |
| 171 | +### Upload to PyPI |
| 172 | + |
| 173 | +```bash |
| 174 | +twine upload dist/* |
| 175 | +``` |
| 176 | + |
| 177 | +When prompted: |
| 178 | +- **Username:** `__token__` |
| 179 | +- **Password:** your PyPI API token |
| 180 | + |
| 181 | +### Install from PyPI |
| 182 | + |
| 183 | +```bash |
| 184 | +pip install onefuse |
| 185 | +``` |
| 186 | + |
| 187 | +Verify the installed version: |
| 188 | +```bash |
| 189 | +python -c "import onefuse; print(onefuse.__version__)" |
| 190 | +``` |
| 191 | + |
| 192 | +--- |
| 193 | + |
| 194 | +> **Note:** PyPI does not allow re-uploading the same version. If a release needs to be corrected after uploading, return to **Section 3** to bump the version before building and uploading again. |
0 commit comments