-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (37 loc) · 1.46 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
# use `make help` to list all targets documented with trailing ## comments
# taken from https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.DEFAULT_GOAL := help
.PHONY: help
help: ## show this help message with common targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# create python virtual environment for dependency management
VENV_DIR := .venv
VENV_TARGET := $(VENV_DIR)/pyvenv.cfg
VENV_BIN := $(VENV_DIR)/bin
.PHONY: venv
venv: $(VENV_TARGET) ## create a new python virtual environment
@echo Use \`source $(VENV_DIR)/bin/activate\` to activate the virtual environment
$(VENV_TARGET):
python3 -m venv $(VENV_DIR)
PYTHON_CMD := $(VENV_BIN)/python3
# hatch environment for development
HATCH_BIN := $(VENV_BIN)/hatch
HATCH_CMD := $(PYTHON_CMD) -m hatch
$(HATCH_BIN): $(VENV_TARGET)
$(PYTHON_CMD) -m pip install hatch
# test suites
.PHONY: test test-examples test-unit test-types
test: test-examples test-unit test-types ## run all test suites
ALL_EXAMPLES := $(wildcard docs/examples/*.py)
test-examples: $(ALL_EXAMPLES) ## run example code test suite
.PHONY: $(ALL_EXAMPLES)
$(ALL_EXAMPLES): $(HATCH_BIN)
$(HATCH_CMD) run python $@
test-unit: ${HATCH_BIN} $(VENV_TARGET) ## run unit test suite
$(HATCH_CMD) test --all --parallel --randomize
test-types: ${HATCH_BIN} $(VENV_TARGET)
$(HATCH_CMD) run types:check
clean:
rm -rf ${VENV_DIR} .mypy_cache .pytest_cache