-
Notifications
You must be signed in to change notification settings - Fork 76
/
Makefile
100 lines (78 loc) · 1.85 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
PACKAGES := clinica test
POETRY ?= poetry
CONDA ?= conda
CONDA_ENV ?= "./env"
.PHONY: help
help: Makefile
@echo "Commands:"
@sed -n 's/^##//p' $<
.PHONY: check.lock
check.lock:
@$(POETRY) check --lock
# clean : Clean project tree.
.PHONY: clean
clean: clean.doc clean.py clean.test
.PHONY: clean.doc
clean.doc:
@$(RM) -rf site/
.PHONY: clean.py
clean.py:
@find . -name __pycache__ -exec $(RM) -r {} +
.PHONY: clean.test
clean.test:
@$(RM) -r .pytest_cache/
## doc : Build the documentation.
.PHONY: doc
doc: clean.doc install.doc
@$(POETRY) run mkdocs build
## env : Bootstrap an environment.
.PHONY: env
env: env.dev
.PHONY: env.conda
env.conda:
@$(CONDA) env create -p $(CONDA_ENV)
.PHONY: env.dev
env.dev: install
## format : Format the codebase.
.PHONY: format
format: install.dev format.black format.isort
.PHONY: format.black
format.black:
$(info Formatting code with black)
@$(POETRY) run black --quiet $(PACKAGES)
.PHONY: format.isort
format.isort:
$(info Formatting code with isort)
@$(POETRY) run isort --quiet $(PACKAGES)
## install : Install the project.
.PHONY: install
install: check.lock
@$(POETRY) install
.PHONY: install.dev
install.dev: check.lock
@$(POETRY) install --only dev
.PHONY: install.doc
install.doc: check.lock
@$(POETRY) install --only docs
## lint : Lint the codebase.
.PHONY: lint
lint: install.dev lint.black lint.isort
.PHONY: lint.black
lint.black:
$(info Linting code with black)
@$(POETRY) run black --check --diff $(PACKAGES)
.PHONY: lint.isort
lint.isort:
$(info Linting code with isort)
@$(POETRY) run isort --check --diff $(PACKAGES)
## lock : Refresh locked dependencies.
.PHONY: lock
lock:
@$(POETRY) lock --no-update
.PHONY: spellcheck
spellcheck: install.dev
@$(POETRY) run codespell
## test : Run unit tests.
.PHONY: test
test: install
@$(POETRY) run python -m pytest -v test/unittests