-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
82 lines (70 loc) · 3.56 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
# Generated by Medikit 0.6.3 on 2018-06-11.
# All changes will be overriden.
# Edit Projectfile and run “make update” (or “medikit update”) to regenerate.
PACKAGE ?= bonobo_sqlalchemy
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 ?=
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
YAPF ?= $(PYTHON) -m yapf
YAPF_OPTIONS ?= -rip
MEDIKIT ?= $(PYTHON) -m medikit
MEDIKIT_UPDATE_OPTIONS ?=
MEDIKIT_VERSION ?= 0.6.3
.PHONY: clean format help install install-dev medikit quick test update update-requirements
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 ~=10.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
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 ~=10.0" wheel
$(PIP) install $(PIP_INSTALL_OPTIONS) -U $(PYTHON_REQUIREMENTS_DEV_INLINE) -r $(PYTHON_REQUIREMENTS_DEV_FILE)
@mkdir -p .medikit; touch $@
endif
quick: #
@printf ""
test: install-dev ## Runs the test suite.
$(PYTEST) $(PYTEST_OPTIONS) tests
format: install-dev ## Reformats the whole python codebase using yapf.
$(YAPF) $(YAPF_OPTIONS) .
$(YAPF) $(YAPF_OPTIONS) Projectfile
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 ~=10.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]?.*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?##"}; {printf " make \033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo