| 1 |
# Simple makefile to simplify repetitive build env management tasks under posix |
| 2 |
|
| 3 |
.DEFAULT_GOAL := test |
| 4 |
|
| 5 |
.PHONY: all clean coverage coverage-xml coverage-html coverage-docs docstyle sync-deps lint typecheck test test-core test-plotting doctest docs docs-test integration |
| 6 |
|
| 7 |
# `all` is a POSIX convention; alias it to the default test target. |
| 8 |
all: test |
| 9 |
|
| 10 |
# Remove build / coverage artifacts from the repo root. |
| 11 |
clean: |
| 12 |
@echo "Cleaning build and coverage artifacts" |
| 13 |
@rm -rf build dist .tox .pytest_cache htmlcov coverage*.xml coverage*.html .coverage |
| 14 |
|
| 15 |
# Directories to run style checks against |
| 16 |
CODE_DIRS ?= doc examples examples_trame pyvista tests |
| 17 |
# Files in top level directory |
| 18 |
CODE_FILES ?= *.py *.rst *.md |
| 19 |
|
| 20 |
coverage: |
| 21 |
@echo "Running coverage" |
| 22 |
@pytest -v --cov pyvista |
| 23 |
|
| 24 |
coverage-xml: |
| 25 |
@echo "Reporting XML coverage" |
| 26 |
@pytest -v --cov pyvista --cov-report xml |
| 27 |
|
| 28 |
coverage-html: |
| 29 |
@echo "Reporting HTML coverage" |
| 30 |
@pytest -v --cov pyvista --cov-report html |
| 31 |
|
| 32 |
coverage-docs: |
| 33 |
@echo "Reporting documentation coverage" |
| 34 |
@make -C doc html SPHINXOPTS="-Q" -b coverage |
| 35 |
@cat doc/_build/coverage/python.txt |
| 36 |
|
| 37 |
# Vale is pinned to match CI (.github/workflows/style-docstring.yml). |
| 38 |
# Install with: `uv tool install [email protected]` |
| 39 |
# Newer vale versions currently fail on the pyvista vocab config. |
| 40 |
docstyle: |
| 41 |
@echo "Running vale" |
| 42 |
@vale --config doc/.vale.ini doc pyvista examples |
| 43 |
|
| 44 |
sync-deps: |
| 45 |
@echo "Installing dev dependencies" |
| 46 |
@uv sync --group dev |
| 47 |
|
| 48 |
lint: |
| 49 |
@echo "Running pre-commit" |
| 50 |
@uv run pre-commit run --all-files |
| 51 |
|
| 52 |
# Extra tox args can be passed via ARGS, e.g. `make typecheck ARGS="--notest"` |
| 53 |
typecheck: |
| 54 |
@echo "Running mypy" |
| 55 |
@uv run tox -e mypy $(ARGS) |
| 56 |
|
| 57 |
# Run tests via tox so local runs match CI exactly. Filter/flag definitions |
| 58 |
# live in tox.ini so they are maintained in one place. |
| 59 |
# Extra pytest args can be passed via ARGS, e.g. `make test ARGS="-n 10 -k filters"` |
| 60 |
test: |
| 61 |
@echo "Running full test suite (matches CI flags)" |
| 62 |
@uv run tox -e test -- $(ARGS) |
| 63 |
|
| 64 |
# Core tests only (matches CI `pyX.Y-core` env). |
| 65 |
test-core: |
| 66 |
@echo "Running core tests (matches CI)" |
| 67 |
@uv run tox -e test-core -- $(ARGS) |
| 68 |
|
| 69 |
# Plotting tests only (matches CI `pyX.Y-plotting` env). |
| 70 |
test-plotting: |
| 71 |
@echo "Running plotting tests (matches CI)" |
| 72 |
@uv run tox -e test-plotting -- $(ARGS) |
| 73 |
|
| 74 |
# Run all docstring tests (matches CI `tox -f doctest`). |
| 75 |
# Executes both doctest-modules and doctest-local tox envs. |
| 76 |
doctest: |
| 77 |
@echo "Running docstring tests (matches CI)" |
| 78 |
@uv run tox -f doctest -- $(ARGS) |
| 79 |
|
| 80 |
# Build the full documentation (matches CI `tox -e docs-build`). |
| 81 |
# Runs pre-gen steps (make_tables, make_external_gallery) and sphinx. |
| 82 |
docs: |
| 83 |
@echo "Building documentation (matches CI)" |
| 84 |
@uv run tox -e docs-build -- $(ARGS) |
| 85 |
|
| 86 |
# Test the built documentation (matches CI `tox -e docs-test`). |
| 87 |
# Requires `make docs` to have been run first. |
| 88 |
docs-test: |
| 89 |
@echo "Testing built documentation (matches CI)" |
| 90 |
@uv run tox -e docs-test -- $(ARGS) |
| 91 |
|
| 92 |
# Run an integration test env (matches CI `tox -e integration-<project>`). |
| 93 |
# Specify project via PROJECT, e.g. `make integration PROJECT=trame`. |
| 94 |
# Supported projects: trame, geovista, mne, pyvistaqt, playwright |
| 95 |
integration: |
| 96 |
@test -n "$(PROJECT)" || { echo "Error: PROJECT is required (trame|geovista|mne|pyvistaqt|playwright)"; exit 1; } |
| 97 |
@echo "Running integration-$(PROJECT) tests (matches CI)" |
| 98 |
@uv run tox -e integration-$(PROJECT) -- $(ARGS) |