|
| 1 | +See the [Scientific Python Developer Guide][spc-dev-intro] for a detailed |
| 2 | +description of best practices for developing scientific packages. |
| 3 | + |
| 4 | +[spc-dev-intro]: https://learn.scientific-python.org/development/ |
| 5 | + |
| 6 | +# Quick development |
| 7 | + |
| 8 | +The fastest way to start with development is to use nox. If you don't have nox, |
| 9 | +you can use `uvx nox` to run it without installing, or `uv tool install nox`. If |
| 10 | +you don't have uv, you can |
| 11 | +[install it a variety of ways](https://docs.astral.sh/uv/getting-started/installation/), |
| 12 | +including with pip, pipx, brew, and just downloading the binary (single file). |
| 13 | + |
| 14 | +To use, run `nox`. This will lint and test using every installed version of |
| 15 | +Python on your system, skipping ones that are not installed. You can also run |
| 16 | +specific jobs: |
| 17 | + |
| 18 | +```console |
| 19 | +$ nox -s lint # Lint only |
| 20 | +$ nox -s tests # Python tests |
| 21 | +$ nox -s docs # Build and serve the docs |
| 22 | +$ nox -s build # Make an SDist and wheel |
| 23 | +``` |
| 24 | + |
| 25 | +Nox handles everything for you, including setting up an temporary virtual |
| 26 | +environment for each run. |
| 27 | + |
| 28 | +# Setting up a development environment manually |
| 29 | + |
| 30 | +You can set up a development environment by running: |
| 31 | + |
| 32 | +```bash |
| 33 | +uv sync |
| 34 | +``` |
| 35 | + |
| 36 | +# Pre-commit |
| 37 | + |
| 38 | +You should prepare pre-commit, which will help you by checking that commits pass |
| 39 | +required checks: |
| 40 | + |
| 41 | +```bash |
| 42 | +uv tool install pre-commit # or brew install pre-commit on macOS |
| 43 | +pre-commit install # Will install a pre-commit hook into the git repo |
| 44 | +``` |
| 45 | + |
| 46 | +You can also/alternatively run `pre-commit run` (changes only) or |
| 47 | +`pre-commit run --all-files` to check even without installing the hook. |
| 48 | + |
| 49 | +# Testing |
| 50 | + |
| 51 | +Use pytest to run the unit checks: |
| 52 | + |
| 53 | +```bash |
| 54 | +uv run pytest |
| 55 | +``` |
| 56 | + |
| 57 | +# Coverage |
| 58 | + |
| 59 | +Use pytest-cov to generate coverage reports: |
| 60 | + |
| 61 | +```bash |
| 62 | +uv run pytest --cov=save-and-restore-api |
| 63 | +``` |
| 64 | + |
| 65 | +# Building docs |
| 66 | + |
| 67 | +You can build and serve the docs using: |
| 68 | + |
| 69 | +```bash |
| 70 | +nox -s docs |
| 71 | +``` |
| 72 | + |
| 73 | +You can build the docs only with: |
| 74 | + |
| 75 | +```bash |
| 76 | +nox -s docs --non-interactive |
| 77 | +``` |
0 commit comments