forked from eradiate/eradiate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
126 lines (96 loc) · 3.33 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
# Detect platform
ifeq ($(OS), Windows_NT)
PLATFORM := win-64
else
uname := $(shell sh -c 'uname 2>/dev/null || echo unknown')
ifeq ($(uname), Darwin)
PLATFORM := osx-64
else ifeq ($(uname), Linux)
PLATFORM := linux-64
else
@echo "Unsupported platform"
exit 1
endif
endif
all:
@echo "Detected platform: $(PLATFORM)"
# -- Dependency management with Pip --------------------------------------------
# Update packaging tools
pip-update-tools:
pip install --upgrade pip-tools pip setuptools
# Update .in files
pip-update-in-files:
python3 requirements/make_pip_in_files.py --quiet
# Lock pip dependencies
# Dev must be compiled first because it constrains the others
# No hashes: doesn't play nicely with RTD when running pip-compile on macOS
pip-compile: pip-update-in-files
rm requirements/dev.txt
touch requirements/dev.txt
@for LAYER in dev main docs tests; do \
echo "Compiling requirements/$${LAYER}.in to requirements/$${LAYER}.txt"; \
pip-compile --upgrade --build-isolation --allow-unsafe \
--output-file requirements/$${LAYER}.txt \
requirements/$${LAYER}.in; \
done
# Lock dependencies
pip-lock: pip-update-tools pip-compile
# Initialise development environment
pip-init:
pip install --upgrade -r requirements/dev.txt
pip install --editable . --no-deps
pip-update: pip-lock pip-init
.PHONY: pip-compile pip-update-tools pip-update-deps pip-init pip-update-in-files
# -- Dependency management with Conda ------------------------------------------
# Generate environment files from pyproject.toml
conda-env:
python3 requirements/make_conda_env.py \
-s "main" \
-o requirements/environment-minimal.yml --quiet
python3 requirements/make_conda_env.py \
-s "main,recommended" \
-o requirements/environment-recommended.yml --quiet
python3 requirements/make_conda_env.py \
-o requirements/environment-dev.yml --quiet
# Lock conda dependencies
conda-lock: conda-env
conda-lock --kind explicit --mamba --file requirements/environment-dev.yml \
--filename-template "requirements/environment-{platform}.lock" \
-p $(PLATFORM)
conda-lock-all: conda-env
conda-lock --kind explicit --mamba --file requirements/environment-dev.yml \
--filename-template "requirements/environment-{platform}.lock" \
-p osx-64 -p linux-64
# Initialise development environment
conda-init:
python3 requirements/check_conda_env.py
conda config --env --add channels conda-forge --add channels eradiate
conda update --file requirements/environment-$(PLATFORM).lock
python3 requirements/copy_envvars.py
pip install --editable . --no-deps
conda-update: conda-lock-all conda-init
.PHONY: conda-env conda-lock conda-lock-all conda-init conda-update
# -- Documentation -------------------------------------------------------------
.PHONY: docs docs-html-plot
docs:
make -C docs html
@echo "Documentation index at docs/_build/html/index.html"
docs-serve:
make -C docs serve
docs-linkcheck:
make -C docs linkcheck
docs-rst:
make -C docs rst-api
make -C docs rst-plugins
docs-render-tutorials: conda-init
jupyter nbconvert tutorials/**/*.ipynb --execute --to notebook --inplace
docs-clean:
make -C docs clean
# -- Testing -------------------------------------------------------------------
.PHONY: test test-doctest test-quick
test:
pytest
test-doctest:
make -C docs doctest
test-quick:
pytest -m "not slow and not regression"