forked from lightwave-lab/lightlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
194 lines (160 loc) · 5.64 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
SHELL := /usr/bin/env bash
# different tests
TESTARGS = --capture=sys --cov=lightlab --cov-config .coveragerc
TESTARGSNB = --nbval-lax
# For devbuild, testbuild
REINSTALL_DEPS = $(shell find lightlab -type f) venv setup.py
# DOCTYPE_DEFAULT can be html or latexpdf
DOCTYPE_DEFAULT = html
# Server ports for CI hosting. You can override by setting an environment variable DOCHOSTPORT
DOCHOSTPORT ?= 8049
default: help ;
venv: venv/bin/activate
venv/bin/activate:
test -e venv/bin/activate || virtualenv -p python3 --prompt "(lightlab-venv) " venv
touch venv/bin/activate
devbuild: venvinfo/devreqs~
venvinfo/devreqs~: $(REINSTALL_DEPS) dev-requirements.txt
( \
source venv/bin/activate; \
pip install -r dev-requirements.txt | grep -v 'Requirement already satisfied'; \
pip install -e . | grep -v 'Requirement already satisfied'; \
)
@mkdir -p venvinfo
touch venvinfo/devreqs~
testbuild: venvinfo/testreqs~
venvinfo/testreqs~: $(REINSTALL_DEPS) test-requirements.txt
( \
source venv/bin/activate; \
pip install -r test-requirements.txt | grep -v 'Requirement already satisfied'; \
pip install -e . | grep -v 'Requirement already satisfied'; \
)
@mkdir -p venvinfo
touch venvinfo/testreqs~
test-unit: testbuild
( \
source venv/bin/activate; \
py.test $(TESTARGS) tests; \
)
test-simple: testbuild
( \
source venv/bin/activate; \
py.test $(TESTARGS) $(TESTARGSNB) tests; \
)
test-lint: testbuild
# This is only used for master
( \
source venv/bin/activate; \
py.test --pylint --flake8 --pylint-rcfile=pylintrc lightlab; \
)
test-lint-errors: testbuild
( \
source venv/bin/activate; \
py.test --pylint --flake8 --pylint-rcfile=pylintrc-errors lightlab; \
)
test-nb: testbuild
( \
source venv/bin/activate; \
py.test $(TESTARGS) $(TESTARGSNB) notebooks/Tests; \
rsync -rau notebooks/Tests/*.ipynb docs/ipynbs/Tests
)
test-unit-all: testbuild
( \
source venv/bin/activate; \
py.test $(TESTARGS) $(TESTARGSNB) tests notebooks/Tests; \
)
# this is equivalent to what is run on CI:development
test: testbuild test-unit-all test-lint-errors ;
clean:
rm -rf dist
rm -rf lightlab.egg-info
rm -rf build
rm -rf venvinfo
rm -rf .cache
rm -rf .pytest_cache
rm -rf .coverage
$(MAKE) -C docs clean
purge: clean
rm -rf venv/*
pip-freeze: devbuild
( \
source venv/bin/activate; \
pipdeptree -lf | grep -E '^\w+' | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U; \
pipdeptree -lf | grep -E '^\w+' | grep -v '^\-e' | grep -v '^#' > dev-requirements-temp.txt; \
)
pip-update: pip-freeze
( \
source venv/bin/activate; \
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U; \
)
# Running Servers (incl. notebooks)
server-config: venv setup.py
source venv/bin/activate; python setup.py server_permissions
jupyter: devbuild
( \
source venv/bin/activate; \
cd notebooks; \
jupyter notebook; \
)
getjpass: venv
venv/bin/python -c 'from notebook.auth import passwd; print(passwd())'
jupyter-password: venv
( \
source venv/bin/activate; \
jupyter notebook password; \
)
monitorhost:
@mkdir -p progress-monitor
cd progress-monitor && python3 -m http.server $(shell cat .monitorhostport)
docbuild: venvinfo/docreqs~
venvinfo/docreqs~: $(REINSTALL_DEPS) notebooks/Tests doc-requirements.txt
( \
source venv/bin/activate; \
pip install -r doc-requirements.txt | grep -v 'Requirement already satisfied'; \
pip install -e . | grep -v 'Requirement already satisfied'; \
)
@mkdir -p venvinfo
@touch venvinfo/docreqs~
docs: docbuild
source venv/bin/activate; $(MAKE) -C docs $(DOCTYPE_DEFAULT)
docs-ci: docbuild
( \
source venv/bin/activate; \
$(MAKE) -C docs html; \
)
dochost: docs
( \
source venv/bin/activate; \
cd docs/_build/$(DOCTYPE_DEFAULT); \
python3 -m http.server $(DOCHOSTPORT); \
)
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo "--- environment ---"
@echo " venv creates a python virtualenv in venv/"
@echo " pip-freeze drops all leaf pip packages into dev-requirements.txt (Use with caution)"
@echo " pip-update updates all pip packages in virtual environment"
@echo " clean clean all build files"
@echo " purge clean and delete virtual environment"
@echo "--- development ---"
@echo " devbuild install dev dependencies, build lightlab, and install inside venv"
@echo "--- testing ---"
@echo " testbuild install test dependencies, build lightlab, and install inside venv"
@echo " test-unit perform basic unit tests"
@echo " test-nb perform unit tests defined with ipynbs"
@echo " test-unit-all perform basic unit tests + ipynbs"
@echo " test-lint perform linting tests (warnings and errors), recommended"
@echo " test-lint-errors perform linting tests (just errors)"
@echo " test perform all unit tests and linting tests"
@echo "--- documentation ---"
@echo " docbuild prepare venv for documentation build"
@echo " docs build documentation"
@echo " dochost build documentation and start local http server"
@echo "--- jupyter server ---"
@echo " server-config prepare a server for persistent lightlab usage (see setup.py)"
@echo " jupyter start a jupyter notebook for development"
@echo " getjpass generate a jupyter compatible password hash"
@echo " jupyter-password change your jupyter notebook user password"
@echo "--- monitor server ---"
@echo " monitorhost undocumented"
.PHONY: help default test docs test-nb test-unit test-unit-all test-lint test-lint-errors clean purge dochost monitorhost pip-freeze pip-update jupyter-password getjpass