-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
144 lines (118 loc) · 4.51 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
# Configuration
APP_ROOT := $(abspath $(lastword $(MAKEFILE_LIST))/..)
APP_NAME := finch
FINCH_WPS_URL := http://localhost:5000
PAVICS_OUTPUT_URL := https://pavics.ouranos.ca/wpsoutputs
# end of configuration
.DEFAULT_GOAL := all
.PHONY: all
all: help
.PHONY: help
help:
@echo "Please use 'make <target>' where <target> is one of:"
@echo " help to print this help message. (Default)"
@echo " install to install app by running 'pip install -e .'"
@echo " develop to install with additional development requirements."
@echo " start to start $(APP_NAME) service as daemon (background process)."
@echo " stop to stop $(APP_NAME) service."
@echo " restart to restart $(APP_NAME) service."
@echo " status to show status of $(APP_NAME) service."
@echo " clean to remove all files generated by build and tests."
@echo "\nTesting targets:"
@echo " test to run tests (but skip long running tests)."
@echo " test-all to run all tests (including long running tests)."
@echo " test-notebooks to test all notebooks."
@echo " refresh-notebooks to re-run all notebooks to refresh all outputs."
@echo " lint to run code style checks with flake8."
@echo "\nSphinx targets:"
@echo " docs to generate HTML documentation with Sphinx."
@echo "\nDeployment targets:"
@echo " dist to build source and wheel package."
## Build targets
.PHONY: install
install:
@echo "Installing application ..."
@-bash -c 'pip install -e .'
@echo "\nStart service with \`make start'"
.PHONY: develop
develop:
@echo "Installing development requirements for tests and docs ..."
@-bash -c 'pip install -e ".[dev]"'
.PHONY: start
start:
@echo "Starting application ..."
@-bash -c "$(APP_NAME) start -d"
.PHONY: stop
stop:
@echo "Stopping application ..."
@-bash -c "$(APP_NAME) stop"
.PHONY: restart
restart: stop start
@echo "Restarting application ..."
.PHONY: status
status:
@echo "Show status ..."
@-bash -c "$(APP_NAME) status"
.PHONY: clean
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
.PHONY: clean-build
clean-build:
@echo "Remove build artifacts ..."
@-rm -fr build/
@-rm -fr dist/
@-rm -fr .eggs/
@-find . -name '*.egg-info' -exec rm -fr {} +
@-find . -name '*.egg' -exec rm -f {} +
@-find . -name '*.log' -exec rm -fr {} +
@-find . -name '*.sqlite' -exec rm -fr {} +
.PHONY: clean-pyc
clean-pyc:
@echo "Remove Python file artifacts ..."
@-find . -name '*.pyc' -exec rm -f {} +
@-find . -name '*.pyo' -exec rm -f {} +
@-find . -name '*~' -exec rm -f {} +
@-find . -name '__pycache__' -exec rm -fr {} +
.PHONY: clean-test
clean-test:
@echo "Remove test artifacts ..."
@-rm -fr .pytest_cache
.PHONY: clean-dist
clean-dist: clean
@echo "Run 'git clean' ..."
@git diff --quiet HEAD || echo "There are uncommited changes! Not doing 'git clean' ..."
@-git clean -dfx
## Test targets
.PHONY: test
test: check_conda
@echo "Running tests (skip slow and online tests) ..."
@bash -c 'pytest -v -m "not slow and not online" tests/'
.PHONY: test-notebooks
test-notebooks:
@echo "Running notebook-based tests"
@bash -c "curl -L https://github.com/Ouranosinc/PAVICS-e2e-workflow-tests/raw/master/notebooks/output-sanitize.cfg --output $(CURDIR)/docs/source/output_sanitize.cfg --silent"
@bash -c "env FINCH_WPS_URL=$(FINCH_WPS_URL) pytest --nbval --verbose $(CURDIR)/docs/source/notebooks/ --sanitize-with $(CURDIR)/docs/source/output_sanitize.cfg --ignore $(CURDIR)/docs/source/notebooks/.ipynb_checkpoints"
.PHONY: refresh-notebooks
refresh-notebooks:
@echo "Refresh all notebook outputs under docs/source/notebooks"
cd docs/source/notebooks; for nb in *.ipynb; do FINCH_WPS_URL="$(FINCH_WPS_URL)" jupyter nbconvert --to notebook --execute --ExecutePreprocessor.timeout=60 --output "$$nb" "$$nb"; sed -i "s@$(FINCH_WPS_URL)/outputs/@$(PAVICS_OUTPUT_URL)/@g" "$$nb"; done; cd $(APP_ROOT)
.PHONY: test-all
test-all:
@echo "Running all tests (including slow and online tests) ..."
@bash -c 'pytest -v tests/'
.PHONY: lint
lint:
@echo "Running flake8 code style checks ..."
@bash -c 'flake8'
## Sphinx targets
.PHONY: docs
docs: check_conda
@echo "Generating docs with Sphinx ..."
@-bash -c '$(MAKE) -C $@ clean html'
@echo "open your browser: open file://$(APP_ROOT)/docs/build/html/index.html"
## Deployment targets
.PHONY: dist
dist: clean
@echo "Builds source and wheel package ..."
@-python setup.py sdist
@-python setup.py bdist_wheel
ls -l dist