| 1 | # Development |
| 2 | |
| 3 | Install [git] and [uv] |
| 4 | |
| 5 | Clone: |
| 6 | |
| 7 | ```console |
| 8 | $ git clone https://github.com/tmux-python/libtmux.git |
| 9 | ``` |
| 10 | |
| 11 | ```console |
| 12 | $ cd libtmux |
| 13 | ``` |
| 14 | |
| 15 | Install packages: |
| 16 | |
| 17 | ```console |
| 18 | $ uv sync --all-extras --dev |
| 19 | ``` |
| 20 | |
| 21 | [installation documentation]: https://docs.astral.sh/uv/getting-started/installation/ |
| 22 | [git]: https://git-scm.com/ |
| 23 | [uv]: https://github.com/astral-sh/uv |
| 24 | |
| 25 | Makefile commands prefixed with `watch_` will watch files and rerun. |
| 26 | |
| 27 | ## Tests |
| 28 | |
| 29 | ```console |
| 30 | $ uv run py.test |
| 31 | ``` |
| 32 | |
| 33 | ### Helpers |
| 34 | |
| 35 | ```console |
| 36 | $ make test |
| 37 | ``` |
| 38 | |
| 39 | Rerun tests on file change: |
| 40 | |
| 41 | ```console |
| 42 | $ make watch_test |
| 43 | ``` |
| 44 | |
| 45 | (requires [entr(1)]) |
| 46 | |
| 47 | ### Pytest plugin |
| 48 | |
| 49 | :::{seealso} |
| 50 | |
| 51 | See {ref}`pytest_plugin`. |
| 52 | |
| 53 | ::: |
| 54 | |
| 55 | ## Documentation |
| 56 | |
| 57 | Default preview server: http://localhost:8023 |
| 58 | |
| 59 | [sphinx-autobuild] will automatically build the docs, watch for file changes and launch a server. |
| 60 | |
| 61 | From home directory: |
| 62 | ```console |
| 63 | $ make start_docs |
| 64 | ``` |
| 65 | |
| 66 | From inside `docs/`: |
| 67 | ```console |
| 68 | $ make start |
| 69 | ``` |
| 70 | |
| 71 | [sphinx-autobuild]: https://github.com/executablebooks/sphinx-autobuild |
| 72 | |
| 73 | ### Manual documentation (the hard way) |
| 74 | |
| 75 | ```console |
| 76 | $ cd docs/ && make html |
| 77 | ``` |
| 78 | |
| 79 | to build. |
| 80 | |
| 81 | ```console |
| 82 | $ make serve |
| 83 | ``` |
| 84 | |
| 85 | to start http server. |
| 86 | |
| 87 | Helpers: |
| 88 | |
| 89 | Build docs: |
| 90 | |
| 91 | ```console |
| 92 | $ make build_docs |
| 93 | ``` |
| 94 | |
| 95 | Serve docs: |
| 96 | |
| 97 | ```console |
| 98 | $ make serve_docs |
| 99 | ``` |
| 100 | |
| 101 | Rebuild docs on file change: |
| 102 | ```console |
| 103 | $ make watch_docs |
| 104 | ``` |
| 105 | (requires [entr(1)]) |
| 106 | |
| 107 | Rebuild docs and run server via one terminal: |
| 108 | ```console |
| 109 | $ make dev_docs |
| 110 | ``` |
| 111 | (requires above, and {command}`make(1)` with |
| 112 | `-J` support, e.g. GNU Make) |
| 113 | |
| 114 | ## Linting |
| 115 | |
| 116 | ### ruff |
| 117 | |
| 118 | The project uses [ruff] to handle formatting, sorting imports and linting. |
| 119 | |
| 120 | ````{tab} Command |
| 121 | |
| 122 | uv: |
| 123 | |
| 124 | ```console |
| 125 | $ uv run ruff |
| 126 | ``` |
| 127 | |
| 128 | If you setup manually: |
| 129 | |
| 130 | ```console |
| 131 | $ ruff check . |
| 132 | ``` |
| 133 | |
| 134 | ```` |
| 135 | |
| 136 | ````{tab} make |
| 137 | |
| 138 | ```console |
| 139 | $ make ruff |
| 140 | ``` |
| 141 | |
| 142 | ```` |
| 143 | |
| 144 | ````{tab} Watch |
| 145 | |
| 146 | ```console |
| 147 | $ make watch_ruff |
| 148 | ``` |
| 149 | |
| 150 | requires [entr(1)]. |
| 151 | |
| 152 | ```` |
| 153 | |
| 154 | ````{tab} Fix files |
| 155 | |
| 156 | uv: |
| 157 | |
| 158 | ```console |
| 159 | $ uv run ruff check . --fix |
| 160 | ``` |
| 161 | |
| 162 | If you setup manually: |
| 163 | |
| 164 | ```console |
| 165 | $ ruff check . --fix |
| 166 | ``` |
| 167 | |
| 168 | ```` |
| 169 | |
| 170 | #### ruff format |
| 171 | |
| 172 | [ruff format] is used for formatting. |
| 173 | |
| 174 | ````{tab} Command |
| 175 | |
| 176 | uv: |
| 177 | |
| 178 | ```console |
| 179 | $ uv run ruff format . |
| 180 | ``` |
| 181 | |
| 182 | If you setup manually: |
| 183 | |
| 184 | ```console |
| 185 | $ ruff format . |
| 186 | ``` |
| 187 | |
| 188 | ```` |
| 189 | |
| 190 | ````{tab} make |
| 191 | |
| 192 | ```console |
| 193 | $ make ruff_format |
| 194 | ``` |
| 195 | |
| 196 | ```` |
| 197 | |
| 198 | ### Type checking |
| 199 | |
| 200 | [mypy] is used for static type checking. |
| 201 | |
| 202 | ````{tab} Command |
| 203 | |
| 204 | uv: |
| 205 | |
| 206 | ```console |
| 207 | $ uv run mypy . |
| 208 | ``` |
| 209 | |
| 210 | If you setup manually: |
| 211 | |
| 212 | ```console |
| 213 | $ mypy . |
| 214 | ``` |
| 215 | |
| 216 | ```` |
| 217 | |
| 218 | ````{tab} make |
| 219 | |
| 220 | ```console |
| 221 | $ make mypy |
| 222 | ``` |
| 223 | |
| 224 | ```` |
| 225 | |
| 226 | ````{tab} Watch |
| 227 | |
| 228 | ```console |
| 229 | $ make watch_mypy |
| 230 | ``` |
| 231 | |
| 232 | requires [entr(1)]. |
| 233 | ```` |
| 234 | |
| 235 | ## Releasing |
| 236 | |
| 237 | Since this software is used by tens of thousands of users daily, we don't want |
| 238 | to release breaking changes. Additionally this is packaged on large Linux/BSD |
| 239 | distros, so we must be mindful of architectural changes. |
| 240 | |
| 241 | Choose what the next version is. Assuming it's version 0.9.0, it could be: |
| 242 | |
| 243 | - 0.9.0post0: postrelease, if there was a packaging issue |
| 244 | - 0.9.1: bugfix / security / tweak |
| 245 | - 0.10.0: breaking changes, new features |
| 246 | |
| 247 | Let's assume we pick 0.9.1 |
| 248 | |
| 249 | `CHANGES`: Assure any PRs merged since last release are mentioned. Give a |
| 250 | thank you to the contributor. Set the header with the new version and the date. |
| 251 | Leave the "current" header and _Insert changes/features/fixes for next release here_ at |
| 252 | the top: |
| 253 | |
| 254 | ``` |
| 255 | current |
| 256 | ------- |
| 257 | - *Insert changes/features/fixes for next release here* |
| 258 | |
| 259 | libtmux 0.9.1 (2020-10-12) |
| 260 | -------------------------- |
| 261 | - :issue:`1`: Fix bug |
| 262 | ``` |
| 263 | |
| 264 | `libtmux/__init__.py` and `__about__.py` - Set version |
| 265 | |
| 266 | ```console |
| 267 | $ git commit -m 'Tag v0.9.1' |
| 268 | ``` |
| 269 | |
| 270 | ```console |
| 271 | $ git tag v0.9.1 |
| 272 | ``` |
| 273 | |
| 274 | After `git push` and `git push --tags`, CI will automatically build and deploy |
| 275 | to [PyPI]. |
| 276 | |
| 277 | ### Releasing via GitHub Actions (manual) |
| 278 | |
| 279 | This isn't used yet since package maintainers may want setup.py in the source. |
| 280 | See [tmuxp issue #625]. |
| 281 | |
| 282 | As of v0.10, [uv] handles virtualenv creation, package requirements, versioning, |
| 283 | building, and publishing. Therefore there is no setup.py or requirements files. |
| 284 | |
| 285 | Update `__version__` in `__about__.py` and `pyproject.toml`: |
| 286 | |
| 287 | ```console |
| 288 | $ git commit -m 'build(libtmux): Tag v0.1.1' |
| 289 | ``` |
| 290 | |
| 291 | ```console |
| 292 | $ git tag v0.1.1 |
| 293 | ``` |
| 294 | |
| 295 | ```console |
| 296 | $ git push |
| 297 | ``` |
| 298 | |
| 299 | ```console |
| 300 | $ git push --tags |
| 301 | ``` |
| 302 | |
| 303 | [twine]: https://twine.readthedocs.io/ |
| 304 | [entr(1)]: http://eradman.com/entrproject/ |
| 305 | [ruff format]: https://docs.astral.sh/ruff/formatter/ |
| 306 | [ruff]: https://ruff.rs |
| 307 | [mypy]: http://mypy-lang.org/ |
| 308 | [PyPI]: https://pypi.org/project/libtmux/ |
| 309 | [tmuxp issue #625]: https://github.com/tmux-python/tmuxp/issues/625 |