Debian Codegraph @

Makefile

raw
1 #!/usr/bin/make -f
2
3 PYTHON=python3
4 SPHINX_APIDOC=sphinx-apidoc
5 TARGET=bpack
6
7 .PHONY: default help dist check fullcheck coverage clean cleaner distclean \
8 lint docs api
9
10 default: help
11
12 help:
13 @echo "Usage: make <TARGET>"
14 @echo "Available targets:"
15 @echo " help - print this help message"
16 @echo " dist - generate the distribution packages (source and wheel)"
17 @echo " check - run a full test (using pytest)"
18 @echo " fullcheck - run a full test (using tox)"
19 @echo " coverage - run tests and generate the coverage report"
20 @echo " clean - clean build artifacts"
21 @echo " cleaner - clean cache files and working directories of al tools"
22 @echo " distclean - clean all the generated files"
23 @echo " lint - perform check with code linter (flake8, black)"
24 @echo " docs - generate the sphinx documentation"
25 @echo " api - update the API source files in the documentation"
26
27 dist:
28 $(PYTHON) -m build
29 $(PYTHON) -m twine check dist/*.tar.gz dist/*.whl
30
31 check:
32 $(PYTHON) -m pytest --doctest-modules $(TARGET)
33
34 fullcheck:
35 $(PYTHON) -m tox run
36
37 coverage:
38 $(PYTHON) -m pytest --doctest-modules --cov=$(TARGET) --cov-report=html --cov-report=term
39
40 clean:
41 $(RM) -r *.*-info build
42 find . -name __pycache__ -type d -exec $(RM) -r {} +
43 # $(RM) -r __pycache__ */__pycache__ */*/__pycache__ */*/*/__pycache__
44 $(RM) $(TARGET)/*.c $(TARGET)/*.cpp $(TARGET)/*.so $(TARGET)/*.o
45 if [ -f docs/Makefile ] ; then $(MAKE) -C docs clean; fi
46 $(RM) -r docs/_build
47
48 cleaner: clean
49 $(RM) -r .coverage htmlcov
50 $(RM) -r .pytest_cache .tox
51 $(RM) -r .mypy_cache .ruff_cache
52 $(RM) -r .ipynb_checkpoints
53
54 distclean: cleaner
55 $(RM) -r dist
56
57 lint:
58 $(PYTHON) -m flake8 --count --statistics $(TARGET)
59 $(PYTHON) -m pydocstyle --count $(TARGET)
60 $(PYTHON) -m isort --check $(TARGET)
61 $(PYTHON) -m black --check $(TARGET)
62 # $(PYTHON) -m mypy --check-untyped-defs --ignore-missing-imports $(TARGET)
63 # ruff check $(TARGET)
64
65 docs:
66 mkdir -p docs/_static
67 $(MAKE) -C docs html
68
69 api:
70 $(RM) -r docs/api
71 $(SPHINX_APIDOC) --module-first --separate --no-toc -o docs/api \
72 --doc-project "$(TARGET) API" --templatedir docs/_templates/apidoc \
73 $(TARGET) $(TARGET)/tests