|
| 1 | +See the [Scikit-HEP Developer introduction][skhep-dev-intro] for a |
| 2 | +detailed description of best practices for developing Scikit-HEP packages. |
| 3 | + |
| 4 | +[skhep-dev-intro]: https://scikit-hep.org/developer/intro |
| 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 `pipx run nox` to run it without installing, or `pipx install nox`. |
| 10 | +If you don't have pipx (pip for applications), then you can install with with |
| 11 | +`pip install pipx` (the only case were installing an application with regular |
| 12 | +pip is reasonable). If you use macOS, then pipx and nox are both in brew, use |
| 13 | +`brew install pipx nox`. |
| 14 | + |
| 15 | +To use, run `nox`. This will lint and test using every installed version of |
| 16 | +Python on your system, skipping ones that are not installed. You can also run |
| 17 | +specific jobs: |
| 18 | + |
| 19 | +```console |
| 20 | +$ nox -s lint # Lint only |
| 21 | +$ nox -s tests-3.9 # Python 3.9 tests only |
| 22 | +$ nox -s docs -- serve # Build and serve the docs |
| 23 | +$ nox -s build # Make an SDist and wheel |
| 24 | +``` |
| 25 | + |
| 26 | +Nox handles everything for you, including setting up an temporary virtual |
| 27 | +environment for each run. |
| 28 | + |
| 29 | + |
| 30 | +# Setting up a development environment manually |
| 31 | + |
| 32 | +You can set up a development environment by running: |
| 33 | + |
| 34 | +```bash |
| 35 | +python3 -m venv .env |
| 36 | +source ./.env/bin/activate |
| 37 | +pip install -v -e .[all] |
| 38 | +``` |
| 39 | + |
| 40 | +# Post setup |
| 41 | + |
| 42 | +You should prepare pre-commit, which will help you by checking that commits |
| 43 | +pass required checks: |
| 44 | + |
| 45 | +```bash |
| 46 | +pip install pre-commit # or brew install pre-commit on macOS |
| 47 | +pre-commit install # Will install a pre-commit hook into the git repo |
| 48 | +``` |
| 49 | + |
| 50 | +You can also/alternatively run `pre-commit run` (changes only) or `pre-commit |
| 51 | +run --all-files` to check even without installing the hook. |
| 52 | + |
| 53 | +# Testing |
| 54 | + |
| 55 | +Use pytest to run the unit checks: |
| 56 | + |
| 57 | +```bash |
| 58 | +pytest |
| 59 | +``` |
| 60 | + |
| 61 | +# Building docs |
| 62 | + |
| 63 | +You can build the docs using: |
| 64 | + |
| 65 | +```bash |
| 66 | +nox -s docs |
| 67 | +``` |
| 68 | + |
| 69 | +You can see a preview with: |
| 70 | + |
| 71 | +```bash |
| 72 | +nox -s docs -- serve |
| 73 | +``` |
| 74 | + |
| 75 | +# Pre-commit |
| 76 | + |
| 77 | +This project uses pre-commit for all style checking. While you can run it with nox, this is such an important tool that it deserves to be installed on its own. Install pre-commit and run: |
| 78 | + |
| 79 | +```bash |
| 80 | +pre-commit run -a |
| 81 | +``` |
| 82 | + |
| 83 | +to check all files. |
0 commit comments