|
2 | 2 |
|
3 | 3 | ## Environment |
4 | 4 |
|
5 | | -Development is currently done using Python 3.11. We recommend using a virtual |
6 | | -environment such as ``venv``: |
| 5 | +Development is currently done using Python 3.13. The environment can be created with: |
7 | 6 |
|
8 | | - python3.11 -m venv venv |
9 | | - source venv/bin/activate |
| 7 | +```shell |
| 8 | + uv sync |
| 9 | +``` |
10 | 10 |
|
11 | | -In your virtual environment, please install all packages for |
12 | | -development by running: |
| 11 | +This creates a .venv folder with the versions specified in the project's uv.lock file. |
13 | 12 |
|
14 | | - pip install -r requirements.txt |
| 13 | +### Pre-commit |
15 | 14 |
|
16 | | -## Pre-Commit |
17 | | - |
18 | | -Also be sure to install `pre-commit`, which is run every time |
19 | | -you make a git commit: |
| 15 | +pre-commit will be installed when syncing uv. It is run every time you make a git |
| 16 | +commit if you call it like this: |
20 | 17 |
|
| 18 | +```shell |
21 | 19 | pre-commit install |
22 | | - |
23 | | -The configuration file for this project is in a |
24 | | -non-standard 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) |
| 20 | +``` |
29 | 21 |
|
30 | 22 | With pre-commit, all code is formatted according to |
31 | | -[ruff](https://github.com/astral-sh/ruff) guidelines. |
| 23 | +[ruff](https://docs.astral.sh/ruff/) guidelines. |
32 | 24 |
|
33 | 25 | To check if your changes pass pre-commit without committing, run: |
34 | 26 |
|
35 | | - pre-commit run --all-files --config=.config/pre-commit-config.yaml |
| 27 | +```shell |
| 28 | + pre-commit run --all-files |
| 29 | +``` |
36 | 30 |
|
37 | | -## Environment Variables |
| 31 | +## Packages |
38 | 32 |
|
39 | | -For the `test_ckan.py` tests to run successfully some configuration is required: |
| 33 | +[uv](https://github.com/astral-sh/uv) is used for package management. If |
| 34 | +you’ve introduced a new package to the source code (i.e. anywhere in `src/`), |
| 35 | +please add it to the `project.dependencies` section of `pyproject.toml` with |
| 36 | +any known version constraints. |
40 | 37 |
|
41 | | -1. The environment variable `HDX_KEY_TEST` needs to contain a valid key from the HDX demo server at |
42 | | -https://demo.data-humdata-org.ahconu.org/ |
43 | | -2. Authentication details for Google Sheets need to be obtained from Mike Rans and either saved in a file named `.gsheet_auth.json` in the home directory (~) or placed in an environment variable `GSHEET_AUTH`. The file is preferred for Windows systems since adding such a long text string to an environment variable in Windows is challenging. |
| 38 | +To add packages required only for testing, add them to the |
| 39 | +`[dependency-groups]`. |
44 | 40 |
|
45 | | -## Testing |
| 41 | +Any changes to the dependencies will be automatically reflected in |
| 42 | +`uv.lock` with `pre-commit`, but you can re-generate the files without committing by |
| 43 | +executing: |
46 | 44 |
|
47 | | -To run the tests and view coverage, execute: |
| 45 | +```shell |
| 46 | + uv lock --upgrade |
| 47 | +``` |
48 | 48 |
|
49 | | - pytest -c .config/pytest.ini --cov hdx --cov-config .config/coveragerc |
| 49 | +## Project |
50 | 50 |
|
51 | | -Follow the example set out already in ``documentation/main.md`` as you write the documentation. |
| 51 | +[uv](https://github.com/astral-sh/uv) is used for project management. The project can be |
| 52 | +built using: |
52 | 53 |
|
53 | | -## Packages |
| 54 | +```shell |
| 55 | + uv build |
| 56 | +``` |
54 | 57 |
|
55 | | -[pip-tools](https://github.com/jazzband/pip-tools) is used for |
56 | | -package management. If you’ve introduced a new package to the |
57 | | -source code (i.e.anywhere in `src/`), please add it to the |
58 | | -`project.dependencies` section of |
59 | | -`pyproject.toml` with any known version constraints. |
| 58 | +Linting and syntax checking can be run with: |
60 | 59 |
|
61 | | -For adding packages for testing or development, add them to |
62 | | -the `test` or `dev` sections under `[project.optional-dependencies]`. |
| 60 | +```shell |
| 61 | + uv run ruff check |
| 62 | +``` |
63 | 63 |
|
64 | | -Any changes to the dependencies will be automatically reflected in |
65 | | -`requirements.txt` with `pre-commit`, but you can re-generate |
66 | | -the file without committing by executing: |
| 64 | +To run the tests and view coverage, execute: |
| 65 | + |
| 66 | +```shell |
| 67 | + uv run pytest |
| 68 | +``` |
| 69 | + |
| 70 | +## Documentation |
67 | 71 |
|
68 | | - pre-commit run pip-compile --all-files --config=.config/pre-commit-config.yaml |
| 72 | +The documentation, including API documentation, is generated using ReadtheDocs and |
| 73 | +MkDocs with Material. As you change the source code, remember to update the |
| 74 | +documentation at `documentation/index.md`. |
0 commit comments