Development¶
Environment¶
Use the devcontainer (Installation). CI builds and tests in the same image, so a local run gives the same answers as CI.
uv sync --extra dev --extra docs
uv run pytest tests/test_environment.py # check the environment first
Tests and checks¶
# The usual run: everything except the exhaustive dataset sweep (about 1,900 tests).
uv run pytest
# Everything, including the sweep of tests/testdataset (about 15,000 tests),
# on all logical cores. Arguments are passed through to pytest.
scripts/run_all_tests.sh
# What CI runs besides the tests.
uv run ruff check geodetic_engine tests
uv run ruff format --check geodetic_engine tests
uv run mypy geodetic_engine
uv run lint-imports
uv run python scripts/sync_pins.py --check
pyproject.toml deselects the dataset marker by default. The sweep is worth
running before a release, or after changing operation selection. It takes
minutes, not seconds, which is why it is opt-in. Tests marked network need a
reachable Georepository instance and credentials.
The bin grid property tests (tests/bingrid/test_properties.py, Hypothesis)
run a fixed set of examples by default, so that every machine gets the same
run. To draw fresh examples, as CI does in a separate step:
uv run pytest tests/bingrid/test_properties.py --hypothesis-profile=geodetic-engine-random
CI runs these as two separate GitHub workflows, so a red check says which kind of problem it is:
Lint and type check (
.github/workflows/lint.yml):ruff,mypy,lint-imports, which checks the import contracts inpyproject.toml(see Architecture), andscripts/sync_pins.py --check, which fails when a copy of the PROJ and pyproj pins in.devcontainer/pins.envis stale.Tests (
.github/workflows/tests.yml): the unit and integration tests, the bin grid property tests with fresh Hypothesis examples, then the dataset sweep, with a coverage floor of 80 % across the unit tests and the sweep.
pyproj wheel builds¶
The pyproj wheels workflow caches the native PROJ build and its dependencies separately for each platform and architecture. Linux caches a manylinux image layer; macOS caches PROJ and its dependency prefix; Windows caches PROJ separately from vcpkg’s installed dependencies. Cache identities include the source versions, build configuration, and relevant toolchain and runner details. Every run still builds and smoke-tests each Python wheel. Linux wheels are also tested in the unmodified manylinux image.
The first build for a set of inputs is cold. To prime caches available to other branches, run the workflow manually on the default branch with publish unchecked. Pull-request caches are scoped to that pull request and cannot prime the default branch or other pull requests. GitHub may evict unused caches, so a later run can be cold again.
For a clean native rebuild, run the workflow manually with rebuild_native checked. This bypasses both native and vcpkg cache restores and saves for that run; it does not delete existing caches. If a restored cache fails validation, delete the affected cache in GitHub Actions or use a clean rebuild to diagnose it. Do not select publish unless a release is intended.
The OSDU database in the release wheel¶
The release wheel ships geodetic_engine/osdudb/_data/proj_data/proj.db, the
official OSDU catalogue built into the pinned pyproj wheel’s own database
(Installation). It is generated, gitignored and never
committed; the build backend includes it in the sdist and the wheel when it is
there. pypi_release builds it before uv build. To build the same file,
and a release like it, locally:
python scripts/build_bundled_osdudb.py
uv build
python scripts/check_installed_wheel.py dist/*.whl dist/*.tar.gz
Both scripts make a new environment with the pyproj wheel
.devcontainer/pins.env pins: the first with this checkout, the
second with the built wheel, reading the pins from the wheel itself. They need
network access to PyPI and the project’s pyproj index. The second runs
scripts/check_package_dist.py there, which compares the shipped database’s
metadata (PROJ release, database layout, EPSG version) with that pyproj’s own
proj.db, then checks that OSDU lookups answer with no PROJ_DATA and no
build step, as CI does on Linux and Windows. No PROJ or pyproj version is
stated in these scripts or the workflows that run them, so moving the pins
needs no change to them.
The devcontainer reads build/proj.db through PROJ_DATA whether the file is
there or not, and the test suite runs with GEODETIC_ENGINE_OSDU_DB=0.
Building the documentation¶
The documentation is built with Sphinx. Pages are written in MyST Markdown, a Markdown dialect with Sphinx’s cross-referencing, so there is no reStructuredText to learn.
uv run --extra docs sphinx-build -W --keep-going -b html docs docs/_build/html
Or build and serve it on http://127.0.0.1:8000 in one step
(--help lists the options, including --live for rebuild-on-save):
scripts/build-docs.sh
Open docs/_build/html/index.html in a browser. For a live preview that
rebuilds on save:
uv run --extra docs sphinx-autobuild docs docs/_build/html
-W turns every warning into an error, and cross-references are checked
strictly (nitpicky = True). A broken link to a class or a page fails the
build, just as a failing test would. Run the docstring examples with:
uv run pytest --doctest-modules geodetic_engine -o addopts=""
If sphinx-build fails at startup with unsupported locale setting, set
LC_ALL=C.UTF-8. The devcontainer sets it for you.
How the site is put together¶
Path |
What it is |
|---|---|
|
Sphinx configuration: the Furo theme, extensions, cross-reference checking |
|
Site styling on top of Furo, and the logo |
|
Local extension: generates the API pages from |
|
Runs first in every kernel that executes a page: plotly figures as HTML a static page can show, and no browser tabs |
|
Figures as SVG files, with the scripts that draw them: |
|
Layout of each generated API page |
|
Hand-written pages |
|
Generated on every build from each subpackage’s |
|
Copied from |
|
Entries of the version switcher, reserved for when a |
Pages with a file_format: mystnb header are notebooks written as Markdown.
Their {code-cell} blocks run during the build, and the output is included in
the page. A cell expected to raise is tagged raises-exception. Any other
error fails the build. Results are cached in docs/_build/.jupyter_cache, so
only changed pages are re-run. The cache keys on a page’s code alone, so after
changing docs/_ext/kernel_startup.py, delete it to re-run every page.
Adding to the API reference¶
Nothing to do. Export the name from its subpackage’s __all__ and it gets a
page. A type that public functions return or accept but that is not exported
can be listed in SUPPORTING in docs/_ext/geodetic_docs.py.
Adding a page¶
Create a .md file in the relevant section and add it to that section’s
toctree. Use an executed page (file_format: mystnb) for anything that shows
coordinates, so the numbers cannot go stale.
Docstring style¶
Docstrings use Google style,
rendered by sphinx.ext.napoleon:
def transform(source_crs, target_crs, x, y=None, z=None, *, operation=None):
"""Transform points between two CRSs in one call.
Longer description: when to use it, what it checks, what it refuses.
Args:
source_crs: CRS the input coordinates are in.
operation: EPSG coordinate operation to apply, for example
``"EPSG:15670"``.
Returns:
The transformed coordinates and their provenance.
Raises:
AmbiguousOperationError: If no operation was given and the
transformation involves an unbound datum change.
Example:
>>> result = transform("EPSG:4258", "EPSG:25832", (10.75, 59.91),
... operation="EPSG:16032")
>>> result.operation.authority_code
'EPSG:16032'
"""
Every public name gets a one-line summary, then a description.
Functions and methods list
Args,Returns, andRaiseswith the package’s own exceptions.Dataclasses list their fields under
Attributes.Cross-reference with Sphinx roles:
:class:`Transformation`,:func:`~geodetic_engine.geodesy.transform`. Refer to private helpers in double backticks, not with a role, because they have no page to link to.An
Exampleis a doctest. It must run offline against the pinned PROJ. Mark a line# doctest: +SKIPonly if it needs a network, credentials or a custom database. Use...for float tails;ELLIPSISis enabled.
Publishing the documentation¶
.github/workflows/docs.yml builds the site in the devcontainer image, like
the lint and test workflows:
Pull requests: build with warnings as errors, run the doctests, run the link check (reported, not blocking), and upload the HTML as an artifact to download and review.
Push to
main: the same, then deploy to GitHub Pages under/dev/.
The site root redirects to /dev/. When the first release is tagged, add a
stable/ build and an entry per release to docs/_static/switcher.json. The
URLs are already versioned, so no page moves.
One-time repository setting: Settings → Pages → Build and deployment → Source: GitHub Actions.