-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
115 lines (91 loc) · 3.49 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/make -f
PYTHON=python3
SPHINX_APIDOC=sphinx-apidoc
TARGET=geomodels
.PHONY: default help dist check fullcheck coverage lint api docs clean cleaner distclean \
ext man data wheels
default: help
help:
@echo "Usage: make <TARGET>"
@echo "Available targets:"
@echo " help - print this help message"
@echo " dist - generate the distribution packages (source and wheel)"
@echo " check - run a full test (using pytest)"
@echo " fullcheck - run a full test (using tox)"
@echo " coverage - run tests and generate the coverage report"
@echo " lint - perform check with code linter (flake8, black)"
@echo " api - update the API source files in the documentation"
@echo " docs - generate the sphinx documentation"
@echo " clean - clean build artifacts"
@echo " cleaner - clean cache files and working directories of al tools"
@echo " distclean - clean all the generated files"
@echo " ext - build Python extensions inplace"
@echo " man - build man pages for CLI programs"
@echo " data - download data needed for testing"
@echo " wheels - build Python wheels"
dist:
$(PYTHON) -m build
$(PYTHON) -m twine check dist/*.tar.gz dist/*.whl
check: ext data
$(PYTHON) -m geomodels info
if [ -d data ]; then export GEOGRAPHICLIB_DATA="$(PWD)/data"; fi && \
$(PYTHON) -m pytest $(TARGET)
fullcheck: data
$(PYTHON) -m tox
coverage: ext data
if [ -d data ]; then export GEOGRAPHICLIB_DATA="$(PWD)/data"; fi && \
$(PYTHON) -m pytest --cov=$(TARGET) --cov-report=html --cov-report=term
lint:
# temporary use --exit-zero
$(PYTHON) -m flake8 --count --statistics --exit-zero $(TARGET)
$(PYTHON) -m isort --check $(TARGET)
$(PYTHON) -m black --check $(TARGET)
# $(PYTHON) -m mypy --check-untyped-defs --ignore-missing-imports $(TARGET)
ruff check $(TARGET)
api: ext
$(RM) -r docs/api
$(SPHINX_APIDOC) --module-first --separate --no-toc -o docs/api \
--doc-project "$(TARGET) API" --templatedir docs/_templates/apidoc \
$(TARGET) \
$(TARGET)/tests $(TARGET)/*.pyx
docs: ext data man
$(MAKE) -C docs html
if [ -d data ]; then export GEOGRAPHICLIB_DATA="$(PWD)/data"; fi && \
$(MAKE) -C docs doctest
clean:
$(RM) -r *.*-info build
find . -name __pycache__ -type d -exec $(RM) -r {} +
# $(RM) -r __pycache__ */__pycache__ */*/__pycache__ */*/*/__pycache__
$(RM) $(TARGET)/*.cpp $(TARGET)/*.so $(TARGET)/*.o
if [ -f docs/Makefile ] ; then $(MAKE) -C docs clean; fi
$(RM) -r docs/_build
$(RM) extern/geographiclib/include/GeographicLib/Config.h
cleaner: clean
$(RM) -r .coverage htmlcov
$(RM) -r .pytest_cache .tox
$(RM) -r .mypy_cache .ruff_cache
$(RM) -r .ipynb_checkpoints
distclean: cleaner
$(RM) -r dist
$(RM) -r data
$(RM) -r wheelhouse
ext: geomodels/_ext.cpp
$(PYTHON) setup.py build_ext --inplace
geomodels/_ext.cpp: $(TARGET)/geoid.pxd $(TARGET)/geoid.pyx \
$(TARGET)/gravity.pxd $(TARGET)/gravity.pyx \
$(TARGET)/magnetic.pxd $(TARGET)/magnetic.pyx
$(PYTHON) -m cython -3 --cplus $(TARGET)/_ext.pyx
man: docs/man/geomodels-cli.1
docs/man/geomodels-cli.1: ext
mkdir -p docs/man
env PYTHONPATH=. argparse-manpage \
--module geomodels.cli --function get_parser \
--project-name "$(TARGET)" \
--url "https://github.com/avalentino/$(TARGET)" \
--author "Antonio Valentino" \
--author-email "antonio dot valentino at tiscali.it" > $@
data: ext
$(PYTHON) -m geomodels install-data -d data recommended
wheels:
# Requires docker
cibuildwheel --platform