Development#

Set up development#

From the repository root, install dependencies and enable commit hooks:

make init
uv run pre-commit install

Run make help to list available commands.

Run tests#

Run the full suite in parallel with coverage:

make test-unit

Run a single test file:

uv run python -m pytest tests/locations/test_location.py

Debug the previous run’s failures, stopping at the first failure:

uv run python -m pytest --lf -x --pdb --no-cov

Build documentation#

Build the site and start a local preview. Warnings fail the build, as in CI.

make build-documentation
uv run python -m http.server 8000 --bind 127.0.0.1 --directory docs/build/html

Open http://127.0.0.1:8000. Rebuild after edits and refresh the page. Press Ctrl+C to stop the preview.

Use Docker#

Build the image and open a development shell:

docker build -t tracarbon .
docker run --rm -it --entrypoint bash tracarbon

To measure with the container, pass options to its tracarbon run entrypoint:

docker run --rm -e TRACARBON_INTERVAL_IN_SECONDS=1 tracarbon --country-code-alpha-iso-2 fr

Measurements require access to supported Linux sensors. Docker on macOS cannot read the Mac’s sensors; use a native installation to measure the Mac.