This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
127 lines (101 loc) · 3.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
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
# Application
APP_ROOT := $(CURDIR)
APP_NAME := copernicus
# Anaconda
CONDA := $(shell command -v conda 2> /dev/null)
ANACONDA_HOME := $(shell conda info --base 2> /dev/null)
CONDA_ENV := $(APP_NAME)
TEMP_FILES := *.egg-info *.log *.sqlite
# 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_NAME) by running 'python setup.py develop'."
@echo " start to start $(APP_NAME) service as daemon (background process)."
@echo " stop to stop $(APP_NAME) service."
@echo " status to show status of $(APP_NAME) service."
@echo " clean to remove *all* files that are not controlled by 'git'. WARNING: use it *only* if you know what you do!"
@echo "\nTesting targets:"
@echo " test to run tests (but skip long running tests)."
@echo " testall to run all tests (including long running tests)."
@echo " pep8 to run pep8 code style checks."
@echo "\nSphinx targets:"
@echo " docs to generate HTML documentation with Sphinx."
## Anaconda targets
.PHONY: check_conda
check_conda:
ifndef CONDA
$(error "Conda is not available. Please install miniconda: https://conda.io/miniconda.html")
endif
.PHONY: conda_env
conda_env: check_conda
@echo "Updating conda environment $(CONDA_ENV) ..."
"$(CONDA)" env update -n $(CONDA_ENV) -f environment.yml
.PHONY: envclean
envclean: check_conda
@echo "Removing conda env $(CONDA_ENV)"
@-"$(CONDA)" remove -n $(CONDA_ENV) --yes --all
## Build targets
.PHONY: bootstrap
bootstrap: check_conda conda_env bootstrap_dev
@echo "Bootstrap ..."
.PHONY: bootstrap_dev
bootstrap_dev:
@echo "Installing development requirements for tests and docs ..."
@-bash -c "$(CONDA) install -y -n $(CONDA_ENV) -c conda-forge pytest flake8 sphinx bumpversion"
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && pip install -r requirements_dev.txt"
.PHONY: install
install: bootstrap
@echo "Installing application ..."
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && python setup.py develop"
@echo "\nStart service with \`make start'"
.PHONY: start
start: check_conda
@echo "Starting application ..."
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && $(APP_NAME) start -d"
.PHONY: stop
stop: check_conda
@echo "Stopping application ..."
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && $(APP_NAME) stop"
.PHONY: status
status: check_conda
@echo "Show status ..."
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && $(APP_NAME) status"
.PHONY: clean
clean: srcclean envclean
@echo "Cleaning generated files ..."
@-for i in $(TEMP_FILES); do \
test -e $$i && rm -v -rf $$i; \
done
.PHONY: srcclean
srcclean:
@echo "Removing *.pyc files ..."
@-find $(APP_ROOT) -type f -name "*.pyc" -print | xargs rm
.PHONY: distclean
distclean: clean
@echo "Cleaning ..."
@git diff --quiet HEAD || echo "There are uncommited changes! Not doing 'git clean' ..."
@-git clean -dfx -e *.bak -e custom.cfg
## Test targets
.PHONY: test
test: check_conda
@echo "Running tests (skip slow and online tests) ..."
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV);pytest -v -m 'not slow and not online'"
.PHONY: testall
testall: check_conda
@echo "Running all tests (including slow and online tests) ..."
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && pytest -v"
.PHONY: pep8
pep8: check_conda
@echo "Running pep8 code style checks ..."
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && flake8"
## Sphinx targets
.PHONY: docs
docs: check_conda
@echo "Generating docs with Sphinx ..."
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV);$(MAKE) -C $@ clean html"
@echo "open your browser: firefox docs/build/html/index.html"