-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
138 lines (101 loc) · 3.5 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
PYTHON := python3
DOCKER := docker
NPM := npm
override srcs = mvnb test setup.py
override venv = .venv
override yarn = .yarn
export PATH := $(CURDIR)/$(yarn)/node_modules/.bin:$(PATH)
.PHONY: setup
setup: $(venv)/bin/mvnb vscode
.PHONY: format
format: black isort
.PHONY: check
check: lint coverage
.PHONY: lint
lint: black-check isort-check flake8
.PHONY: black
black: $(venv)/bin/black
$(venv)/bin/black -q $(srcs)
.PHONY: isort
isort: $(venv)/bin/isort
$(venv)/bin/isort $(srcs)
.PHONY: black-check
black-check: $(venv)/bin/black
$(venv)/bin/black -q --check $(srcs)
.PHONY: isort-check
isort-check: $(venv)/bin/isort
$(venv)/bin/isort -c $(srcs)
.PHONY: flake8
flake8: $(venv)/bin/flake8
$(venv)/bin/flake8 $(srcs)
.PHONY: test
test: $(venv)/bin/pytest $(venv)/bin/mvnb
$(venv)/bin/pytest
.PHONY: coverage
coverage: $(venv)/bin/pytest $(venv)/bin/mvnb
$(venv)/bin/pytest --cov --cov-report=html --cov-report=term --cov-report=xml
.PHONY: build
build: $(yarn)/node_modules/.bin/yarn $(venv)/bin/pyproject-build
$(venv)/bin/pyproject-build
.PHONY: build-docker
build-docker:
$(DOCKER) build -t mvnb .
.PHONY: vscode
vscode: .vscode/settings.json
# clean tasks -----------------------------------------------------------------
.PHONY: clean
clean: $(shell grep -o '^clean-[^:]*' Makefile)
.PHONY: clean-venv
clean-venv:
rm -rf .venv .yarn mvnb-gui/yarn
.PHONY: clean-pyc
clean-pyc:
find . -type f -name '*.py[co]' -delete
find . -type d -name __pycache__ -delete
.PHONY: clean-gui
clean-gui:
rm -rf mvnb-gui/.parcel-cache mvnb-gui/node_modules
rm -rf mvnb/gui
.PHONY: clean-test
clean-test:
rm -rf .pytest_cache
.PHONY: clean-coverage
clean-coverage: clean-test
rm -rf .coverage coverage.xml htmlcov
.PHONY: clean-build
clean-build: clean-gui
rm -rf dist mvnb.egg-info
.PHONY: clean-vscode
clean-vscode:
rm -rf .vscode
# venv creation ---------------------------------------------------------------
$(venv)/bin/python $(venv)/bin/pip:
$(PYTHON) -m venv $(venv) --clear --upgrade-deps
$(venv)/bin/mvnb: $(yarn)/node_modules/.bin/yarn $(venv)/bin/pip
$(venv)/bin/pip install -e .
# builder installation --------------------------------------------------------
$(yarn)/node_modules/.bin/yarn:
mkdir -p $(yarn)
echo '{}' > $(yarn)/package.json
cd $(yarn) && $(NPM) install --no-package-lock yarn
cd mvnb-gui && ln -s ../$(yarn)/node_modules/.bin/yarn
$(venv)/bin/pyproject-build: $(venv)/bin/pip
$(venv)/bin/pip install -I build
# checker installation --------------------------------------------------------
$(venv)/bin/black: $(venv)/bin/pip
$(venv)/bin/pip install -I black
$(venv)/bin/isort: $(venv)/bin/pip
$(venv)/bin/pip install -I isort
$(venv)/bin/flake8: $(venv)/bin/pip
$(venv)/bin/pip install -I flake8 flake8-black flake8-tidy-imports
$(venv)/bin/pytest: $(venv)/bin/pip
$(venv)/bin/pip install -I pytest pytest-asyncio pytest-timeout pytest-cov
# editor setting generation ---------------------------------------------------
.vscode/settings.json:
mkdir -p .vscode
echo '{' > .vscode/settings.json
echo ' "coverage-gutters.showLineCoverage": true,' >> .vscode/settings.json
echo ' "python.linting.flake8Enabled": true,' >> .vscode/settings.json
echo ' "python.testing.pytestEnabled": true,' >> .vscode/settings.json
echo ' "python.defaultInterpreterPath": "$(venv)/bin/python",' >> .vscode/settings.json
echo '}' >> .vscode/settings.json