-
Notifications
You must be signed in to change notification settings - Fork 219
/
Makefile
86 lines (72 loc) · 2.87 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Build, package, test, and clean
PROJECT=pygmt
TESTDIR=tmp-test-dir-with-unique-name
PYTEST_COV_ARGS=--cov=$(PROJECT) --cov-config=../pyproject.toml \
--cov-report=term-missing --cov-report=xml --cov-report=html
FORMAT_FILES=$(PROJECT) doc/conf.py examples
help:
@echo "Commands:"
@echo ""
@echo " install install in editable mode"
@echo " package build source and wheel distributions"
@echo " test run the test suite (including some doctests) and report coverage"
@echo " fulltest run the test suite (including all doctests)"
@echo " doctest run the doctests only"
@echo " test_no_images run the test suite (including all doctests) but skip image comparisons"
@echo " format run ruff to automatically format the code"
@echo " check run ruff to check code style and quality"
@echo " codespell run codespell to check common misspellings"
@echo " typecheck run mypy for static type check"
@echo " clean clean up build and generated files"
@echo " distclean clean up build and generated files, including project metadata files"
@echo ""
install:
python -m pip install --no-deps -e .
package:
python -m build
_runtest:
# Run in a tmp folder to make sure the tests are run on the installed version
mkdir -p $(TESTDIR)
@echo ""
@cd $(TESTDIR); python -c "import $(PROJECT); $(PROJECT).show_versions()"
@echo ""
cd $(TESTDIR); PYGMT_USE_EXTERNAL_DISPLAY="false" pytest $(PYTEST_ARGS) --pyargs $(PROJECT)
@echo ""
if [ -e $(TESTDIR)/coverage.xml ]; then cp $(TESTDIR)/coverage.xml .; fi
if [ -e $(TESTDIR)/htmlcov ]; then cp -r $(TESTDIR)/htmlcov .; fi
rm -r $(TESTDIR)
# run regular tests (unit tests + some doctests)
test: PYTEST_ARGS=--doctest-plus $(PYTEST_COV_ARGS) ${PYTEST_EXTRA}
test: _runtest
# run full tests (unit tests + all doctests)
fulltest: PYTEST_ARGS=${PYTEST_EXTRA}
fulltest: _runtest
# run doctests only
doctest: PYTEST_ARGS=--ignore=../${PROJECT}/tests ${PYTEST_EXTRA}
doctest: _runtest
# run tests without image comparisons
# run pytest without the --mpl option to disable image comparisons
# use '-o addopts' to override 'addopts' settings in pyproject.toml file
test_no_images: PYTEST_ARGS=-o addopts="--verbose --durations=0 --durations-min=0.2 --doctest-modules"
test_no_images: _runtest
format:
ruff check --fix --exit-zero $(FORMAT_FILES)
ruff format $(FORMAT_FILES)
pre-commit run --all-files
check:
ruff check $(FORMAT_FILES)
ruff format --check $(FORMAT_FILES)
codespell:
@codespell
typecheck:
mypy ${PROJECT}
clean:
find . -name "*.pyc" -exec rm -v {} +
find . -name "*~" -exec rm -v {} +
find . -type d -name "__pycache__" -exec rm -rv {} +
rm -rvf build dist .eggs MANIFEST .coverage htmlcov coverage.xml
rm -rvf .benchmarks .cache .mypy_cache .pytest_cache .ruff_cache
rm -rvf $(TESTDIR)
rm -rvf baseline result_images results
distclean: clean
rm -rvf *.egg-info