-
Notifications
You must be signed in to change notification settings - Fork 146
/
Makefile
140 lines (122 loc) · 6.67 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
# Generated by Medikit 0.7.3 on 2019-07-20.
# All changes will be overriden.
# Edit Projectfile and run “make update” (or “medikit update”) to regenerate.
PACKAGE ?= bonobo
PYTHON ?= $(shell which python || echo python)
PYTHON_BASENAME ?= $(shell basename $(PYTHON))
PYTHON_DIRNAME ?= $(shell dirname $(PYTHON))
PYTHON_REQUIREMENTS_FILE ?= requirements.txt
PYTHON_REQUIREMENTS_INLINE ?=
PYTHON_REQUIREMENTS_DEV_FILE ?= requirements-dev.txt
PYTHON_REQUIREMENTS_DEV_INLINE ?=
PYTHON_REQUIREMENTS_DOCKER_FILE ?= requirements-docker.txt
PYTHON_REQUIREMENTS_DOCKER_INLINE ?=
PYTHON_REQUIREMENTS_JUPYTER_FILE ?= requirements-jupyter.txt
PYTHON_REQUIREMENTS_JUPYTER_INLINE ?=
PYTHON_REQUIREMENTS_SQLALCHEMY_FILE ?= requirements-sqlalchemy.txt
PYTHON_REQUIREMENTS_SQLALCHEMY_INLINE ?=
QUICK ?=
PIP ?= $(PYTHON) -m pip
PIP_INSTALL_OPTIONS ?=
VERSION ?= $(shell git describe 2>/dev/null || git rev-parse --short HEAD)
PYTEST ?= $(PYTHON_DIRNAME)/pytest
PYTEST_OPTIONS ?= --capture=no --cov=$(PACKAGE) --cov-report html
SPHINX_BUILD ?= $(PYTHON_DIRNAME)/sphinx-build
SPHINX_OPTIONS ?=
SPHINX_SOURCEDIR ?= docs
SPHINX_BUILDDIR ?= $(SPHINX_SOURCEDIR)/_build
SPHINX_AUTOBUILD ?= $(PYTHON_DIRNAME)/sphinx-autobuild
MEDIKIT ?= $(PYTHON) -m medikit
MEDIKIT_UPDATE_OPTIONS ?=
MEDIKIT_VERSION ?= 0.7.3
.PHONY: $(SPHINX_SOURCEDIR) clean format help install install-dev install-docker install-jupyter install-sqlalchemy medikit quick test update update-requirements watch-$(SPHINX_SOURCEDIR)
install: .medikit/install ## Installs the project.
.medikit/install: $(PYTHON_REQUIREMENTS_FILE) setup.py
$(eval target := $(shell echo $@ | rev | cut -d/ -f1 | rev))
ifeq ($(filter quick,$(MAKECMDGOALS)),quick)
@printf "Skipping \033[36m%s\033[0m because of \033[36mquick\033[0m target.\n" $(target)
else ifneq ($(QUICK),)
@printf "Skipping \033[36m%s\033[0m because \033[36m$$QUICK\033[0m is not empty.\n" $(target)
else
@printf "Applying \033[36m%s\033[0m target...\n" $(target)
$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip ~=19.0" wheel
$(PIP) install $(PIP_INSTALL_OPTIONS) -U $(PYTHON_REQUIREMENTS_INLINE) -r $(PYTHON_REQUIREMENTS_FILE)
@mkdir -p .medikit; touch $@
endif
clean: ## Cleans up the working copy.
rm -rf build dist *.egg-info .medikit/install .medikit/install-dev .medikit/install-docker .medikit/install-jupyter .medikit/install-sqlalchemy
find . -name __pycache__ -type d | xargs rm -rf
install-dev: .medikit/install-dev ## Installs the project (with dev dependencies).
.medikit/install-dev: $(PYTHON_REQUIREMENTS_DEV_FILE) setup.py
$(eval target := $(shell echo $@ | rev | cut -d/ -f1 | rev))
ifeq ($(filter quick,$(MAKECMDGOALS)),quick)
@printf "Skipping \033[36m%s\033[0m because of \033[36mquick\033[0m target.\n" $(target)
else ifneq ($(QUICK),)
@printf "Skipping \033[36m%s\033[0m because \033[36m$$QUICK\033[0m is not empty.\n" $(target)
else
@printf "Applying \033[36m%s\033[0m target...\n" $(target)
$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip ~=19.0" wheel
$(PIP) install $(PIP_INSTALL_OPTIONS) -U $(PYTHON_REQUIREMENTS_DEV_INLINE) -r $(PYTHON_REQUIREMENTS_DEV_FILE)
@mkdir -p .medikit; touch $@
endif
quick: #
@printf ""
install-docker: .medikit/install-docker ## Installs the project (with docker dependencies).
.medikit/install-docker: $(PYTHON_REQUIREMENTS_DOCKER_FILE) setup.py
$(eval target := $(shell echo $@ | rev | cut -d/ -f1 | rev))
ifeq ($(filter quick,$(MAKECMDGOALS)),quick)
@printf "Skipping \033[36m%s\033[0m because of \033[36mquick\033[0m target.\n" $(target)
else ifneq ($(QUICK),)
@printf "Skipping \033[36m%s\033[0m because \033[36m$$QUICK\033[0m is not empty.\n" $(target)
else
@printf "Applying \033[36m%s\033[0m target...\n" $(target)
$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip ~=19.0" wheel
$(PIP) install $(PIP_INSTALL_OPTIONS) -U $(PYTHON_REQUIREMENTS_DOCKER_INLINE) -r $(PYTHON_REQUIREMENTS_DOCKER_FILE)
@mkdir -p .medikit; touch $@
endif
install-jupyter: .medikit/install-jupyter ## Installs the project (with jupyter dependencies).
.medikit/install-jupyter: $(PYTHON_REQUIREMENTS_JUPYTER_FILE) setup.py
$(eval target := $(shell echo $@ | rev | cut -d/ -f1 | rev))
ifeq ($(filter quick,$(MAKECMDGOALS)),quick)
@printf "Skipping \033[36m%s\033[0m because of \033[36mquick\033[0m target.\n" $(target)
else ifneq ($(QUICK),)
@printf "Skipping \033[36m%s\033[0m because \033[36m$$QUICK\033[0m is not empty.\n" $(target)
else
@printf "Applying \033[36m%s\033[0m target...\n" $(target)
$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip ~=19.0" wheel
$(PIP) install $(PIP_INSTALL_OPTIONS) -U $(PYTHON_REQUIREMENTS_JUPYTER_INLINE) -r $(PYTHON_REQUIREMENTS_JUPYTER_FILE)
@mkdir -p .medikit; touch $@
endif
install-sqlalchemy: .medikit/install-sqlalchemy ## Installs the project (with sqlalchemy dependencies).
.medikit/install-sqlalchemy: $(PYTHON_REQUIREMENTS_SQLALCHEMY_FILE) setup.py
$(eval target := $(shell echo $@ | rev | cut -d/ -f1 | rev))
ifeq ($(filter quick,$(MAKECMDGOALS)),quick)
@printf "Skipping \033[36m%s\033[0m because of \033[36mquick\033[0m target.\n" $(target)
else ifneq ($(QUICK),)
@printf "Skipping \033[36m%s\033[0m because \033[36m$$QUICK\033[0m is not empty.\n" $(target)
else
@printf "Applying \033[36m%s\033[0m target...\n" $(target)
$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip ~=19.0" wheel
$(PIP) install $(PIP_INSTALL_OPTIONS) -U $(PYTHON_REQUIREMENTS_SQLALCHEMY_INLINE) -r $(PYTHON_REQUIREMENTS_SQLALCHEMY_FILE)
@mkdir -p .medikit; touch $@
endif
test: install-dev ## Runs the test suite.
$(PYTEST) $(PYTEST_OPTIONS) tests
$(SPHINX_SOURCEDIR): install-dev ##
$(SPHINX_BUILD) -b html -D latex_paper_size=a4 $(SPHINX_OPTIONS) $(SPHINX_SOURCEDIR) $(SPHINX_BUILDDIR)/html
watch-$(SPHINX_SOURCEDIR): ##
$(SPHINX_AUTOBUILD) $(SPHINX_SOURCEDIR) $(shell mktemp -d)
format: ## Reformats the whole codebase using our standards (requires black and isort).
black -l 120 .
isort -rc -o mondrian -o whistle -y .
medikit: # Checks installed medikit version and updates it if it is outdated.
@$(PYTHON) -c 'import medikit, pip, sys; from packaging.version import Version; sys.exit(0 if (Version(medikit.__version__) >= Version("$(MEDIKIT_VERSION)")) and (Version(pip.__version__) < Version("10")) else 1)' || $(PYTHON) -m pip install -U "pip ~=19.0" "medikit>=$(MEDIKIT_VERSION)"
update: medikit ## Update project artifacts using medikit.
$(MEDIKIT) update $(MEDIKIT_UPDATE_OPTIONS)
update-requirements: ## Update project artifacts using medikit, including requirements files.
MEDIKIT_UPDATE_OPTIONS="--override-requirements" $(MAKE) update
help: ## Shows available commands.
@echo "Available commands:"
@echo
@grep -E '^[a-zA-Z_-]+:.*?##[\s]?.*$$' --no-filename $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?##"}; {printf " make \033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo