-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (62 loc) · 2 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
PROJNAME=bcsim
WEBPATH=docs/index.html
# --------------------------------------------
define BROWSER_PYSCRIPT
import webbrowser
from pathlib import Path
p = Path('.').resolve()/'${WEBPATH}'
webbrowser.open(f'file://{p}', new=2)
endef
export BROWSER_PYSCRIPT
BROWSER?=python3 -c "$$BROWSER_PYSCRIPT"
# --------------------------------------------
all: help
# --------------------------------------------
.PHONY: setup
setup: ## initialize the project and create python venv
ifeq (,$(wildcard .init/setup))
@(which poetry > /dev/null 2>&1) || \
(echo "pymids requires poetry. See README for instructions."; exit 1)
mkdir .init
touch .init/setup
poetry install
else
@echo "Initial setup is already complete. If you are having issues, run:"
@echo
@echo "make reset"
@echo "make setup"
@echo
endif
# --------------------------------------------
.PHONY: reset
reset: clean ## reset the project for clean setup
@echo Resetting project state
@rm -rf .mypy_cache
@rm -rf .venv .init
# -------------------------
.PHONY: clean
clean: ## Purge project build artifacts
@echo Cleaning project build artifacts
@rm -rf build/
@rm -rf dist/
@find . -type d -name __pycache__ -exec rm -rf {} \; -prune
@find . -type d -name .pytest_cache -exec rm -rf {} \; -prune
@find . -type d -name .eggs -exec rm -rf {} \; -prune
@find . -type d -name htmlcov -exec rm -rf {} \; -prune
@find . -type d -name *.egg-info -exec rm -rf {} \; -prune
@find . -type f -name *.egg -delete
@find . -type f -name *.pyc -delete
@find . -type f -name *.pyo -delete
@find . -type f -name *.coverage -delete
# --------------------------------------------
.PHONY: docs
docs: ## Generate project documentation
pdoc3 --html --template-dir=docs -o docs src/${PROJNAME} --force
${BROWSER}
# --------------------------------------------
.PHONY: help
help: ## Show help
@echo Please specify a target. Choices are:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk \
'BEGIN {FS = ":.*?## "}; \
{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'