|
| 1 | +# Development |
| 2 | + |
| 3 | +## Environment |
| 4 | + |
| 5 | +Development is currently done using Python 3.11. We recommend using a virtual |
| 6 | +environment such as ``venv``: |
| 7 | + |
| 8 | + python3.11 -m venv venv |
| 9 | + source venv/bin/activate |
| 10 | + |
| 11 | +In your virtual environment, please install all packages for |
| 12 | +development by running: |
| 13 | + |
| 14 | + pip install -r requirements.txt |
| 15 | + |
| 16 | +## Pre-Commit |
| 17 | + |
| 18 | +Also be sure to install `pre-commit`, which is run every time |
| 19 | +you make a git commit: |
| 20 | + |
| 21 | + pre-commit install |
| 22 | + |
| 23 | +The configuration file for this project is in a |
| 24 | +non-start location. Thus, you will need to edit your |
| 25 | +`.git/hooks/pre-commit` file to reflect this. Change |
| 26 | +the line that begins with `ARGS` to: |
| 27 | + |
| 28 | + ARGS=(hook-impl --config=.config/pre-commit-config.yaml --hook-type=pre-commit) |
| 29 | + |
| 30 | +With pre-commit, all code is formatted according to |
| 31 | +[black]("https://github.com/psf/black") and |
| 32 | +[ruff]("https://github.com/charliermarsh/ruff") guidelines. |
| 33 | + |
| 34 | +To check if your changes pass pre-commit without committing, run: |
| 35 | + |
| 36 | + pre-commit run --all-files --config=.config/pre-commit-config.yaml |
| 37 | + |
| 38 | +## Testing |
| 39 | + |
| 40 | +To run the tests and view coverage, execute: |
| 41 | + |
| 42 | + pytest -c .config/pytest.ini --cov hdx --cov-config .config/coveragerc |
| 43 | + |
| 44 | +Follow the example set out already in ``api.rst`` as you write the documentation. |
| 45 | + |
| 46 | +## Packages |
| 47 | + |
| 48 | +[pip-tools](https://github.com/jazzband/pip-tools) is used for |
| 49 | +package management. If you’ve introduced a new package to the |
| 50 | +source code (i.e.anywhere in `src/`), please add it to the |
| 51 | +`project.dependencies` section of |
| 52 | +`pyproject.toml` with any known version constraints. |
| 53 | + |
| 54 | +For adding packages for testing or development, add them to |
| 55 | +the `test` or `dev` sections under `[project.optional-dependencies]`. |
| 56 | + |
| 57 | +Any changes to the dependencies will be automatically reflected in |
| 58 | +`requirements.txt` with `pre-commit`, but you can re-generate |
| 59 | +the file without committing by executing: |
| 60 | + |
| 61 | + pre-commit run pip-compile --all-files --config=.config/pre-commit-config.yaml |
0 commit comments