-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
66 lines (53 loc) · 2.13 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
print-% : ; @echo $* = $($*)
PROJECT_NAME = daxbench
COPYRIGHT = "AdaCompNUS All Rights Reserved."
PROJECT_PATH = $(PROJECT_NAME)
SHELL = /bin/bash
SOURCE_FOLDERS = $(PROJECT_PATH) docs
PYTHON_FILES = $(shell find $(SOURCE_FOLDERS) -type f -name "*.py" -o -name "*.pyi")
COMMIT_HASH = $(shell git log -1 --format=%h)
PATH := $(HOME)/go/bin:$(PATH)
PYTHON ?= $(shell command -v python3 || command -v python)
PYTESTOPTS ?=
.PHONY: default
default: install
# Tools Installation
check_pip_install = $(PYTHON) -m pip show $(1) &>/dev/null || (cd && $(PYTHON) -m pip install $(1) --upgrade)
check_pip_install_extra = $(PYTHON) -m pip show $(1) &>/dev/null || (cd && $(PYTHON) -m pip install $(2) --upgrade)
docs-install:
$(call check_pip_install_extra,pydocstyle,pydocstyle[toml])
$(call check_pip_install,doc8)
$(call check_pip_install,sphinx)
$(call check_pip_install,sphinx-rtd-theme)
$(call check_pip_install,sphinx-autoapi)
$(call check_pip_install,sphinx-autobuild)
$(call check_pip_install,sphinx-copybutton)
$(call check_pip_install,sphinxcontrib-katex)
$(call check_pip_install,sphinxcontrib-bibtex)
$(call check_pip_install,sphinx-autodoc-typehints)
$(call check_pip_install,myst-nb)
$(call check_pip_install_extra,sphinxcontrib-spelling,sphinxcontrib-spelling pyenchant)
# Documentation
docstyle: docs-install
make -C docs clean
$(PYTHON) -m pydocstyle $(PROJECT_PATH) && doc8 docs && make -C docs html SPHINXOPTS="-W"
docs: docs-install
$(PYTHON) -m sphinx_autobuild --watch $(PROJECT_PATH) --open-browser docs/source docs/build
spelling: docs-install
make -C docs clean
make -C docs spelling SPHINXOPTS="-W"
clean-docs:
make -C docs clean
# Utility functions
clean-py:
find . -type f -name '*.py[co]' -delete
find . -depth -type d -name "__pycache__" -exec rm -r "{}" +
find . -depth -type d -name ".ruff_cache" -exec rm -r "{}" +
find . -depth -type d -name ".mypy_cache" -exec rm -r "{}" +
find . -depth -type d -name ".pytest_cache" -exec rm -r "{}" +
rm tests/.coverage
rm tests/coverage.xml
clean-build:
rm -rf build/ dist/
rm -rf *.egg-info .eggs
clean: clean-py clean-build clean-docs