-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
182 lines (161 loc) · 5.15 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
PYTHON_INTERPRETER=python3
VENV_PATH=.venv
PYTHON_BIN=$(VENV_PATH)/bin/python
PIP_BIN=$(VENV_PATH)/bin/pip
FLAKE_BIN=$(VENV_PATH)/bin/flake8
PYTEST_BIN=$(VENV_PATH)/bin/pytest
SPHINX_RELOAD_BIN=$(PYTHON_BIN) docs/sphinx_reload.py
TOX_BIN=$(VENV_PATH)/bin/tox
TWINE_BIN=$(VENV_PATH)/bin/twine
PACKAGE_NAME=project-composer
PACKAGE_SLUG=`echo $(PACKAGE_NAME) | tr '-' '_'`
APPLICATION_NAME=project_composer
# Formatting variables, FORMATRESET is always to be used last to close formatting
FORMATBLUE:=$(shell tput setab 4)
FORMATBOLD:=$(shell tput bold)
FORMATRESET:=$(shell tput sgr0)
help:
@echo "Please use 'make <target> [<target>...]' where <target> is one of"
@echo
@echo " Cleaning"
@echo " ========"
@echo
@echo " clean -- to clean EVERYTHING (Warning)"
@echo " clean-doc -- to remove documentation builds"
@echo " clean-install -- to clean Python side installation"
@echo " clean-pycache -- to recursively remove all Python cache files"
@echo
@echo " Installation"
@echo " ============"
@echo
@echo " install -- to install this project with virtualenv and Pip"
@echo " freeze-dependencies -- to write installed dependencies versions in 'frozen.txt'"
@echo
@echo " Documentation"
@echo " ============="
@echo
@echo " docs -- to build documentation"
@echo " livedocs -- to run a 'live reloaded' server for documentation"
@echo " diagrams -- to build diagrams and deploy them in documentation"
@echo
@echo " Quality"
@echo " ======="
@echo
@echo " check-release -- to check package release before uploading it to PyPi"
@echo " flake -- to launch Flake8 checking"
@echo " quality -- to launch run quality tasks and checks"
@echo " test -- to launch base test suite using Pytest"
@echo " tox -- to launch tests for every Tox environments"
@echo
@echo " Release"
@echo " ======="
@echo
@echo " release -- to release latest package version on PyPi"
@echo
clean-pycache:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Clear Python cache <---$(FORMATRESET)\n"
@echo ""
rm -Rf .pytest_cache
find . -type d -name "__pycache__"|xargs rm -Rf
find . -name "*\.pyc"|xargs rm -f
rm -Rf .tox
.PHONY: clean-pycache
clean-install:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Clear installation <---$(FORMATRESET)\n"
@echo ""
rm -Rf dist
rm -Rf $(VENV_PATH)
rm -Rf $(PACKAGE_SLUG).egg-info
.PHONY: clean-install
clean-doc:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Clear documentation <---$(FORMATRESET)\n"
@echo ""
rm -Rf docs/_build
.PHONY: clean-doc
clean: clean-doc clean-install clean-pycache
.PHONY: clean
venv:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Install virtual environment <---$(FORMATRESET)\n"
@echo ""
virtualenv -p $(PYTHON_INTERPRETER) $(VENV_PATH)
.PHONY: venv
install: venv
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Install everything for development <---$(FORMATRESET)\n"
@echo ""
$(PIP_BIN) install -e .[dev,quality,doc,doc-live,release]
.PHONY: install
docs:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Build documentation <---$(FORMATRESET)\n"
@echo ""
cd docs && make html
.PHONY: docs
diagrams:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Build diagrams <---$(FORMATRESET)\n"
@echo ""
$(PYTHON_BIN) diags/django.py
$(PYTHON_BIN) diags/icons.py
$(PYTHON_BIN) diags/processors.py
$(PYTHON_BIN) diags/resolver.py
$(PYTHON_BIN) diags/workflow.py
.PHONY: diagrams
livedocs:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Watching documentation sources <---$(FORMATRESET)\n"
@echo ""
$(SPHINX_RELOAD_BIN)
.PHONY: livedocs
flake:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Running Flake check <---$(FORMATRESET)\n"
@echo ""
$(FLAKE_BIN) --statistics --show-source $(APPLICATION_NAME) tests diags
.PHONY: flake
test:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Running Tests <---$(FORMATRESET)\n"
@echo ""
$(PYTEST_BIN) tests/
.PHONY: test
freeze-dependencies:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Freezing dependencies versions <---$(FORMATRESET)\n"
@echo ""
$(PYTHON_BIN) freezer.py ${PACKAGE_NAME} --destination=frozen.txt
.PHONY: freeze-dependencies
build-package:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Building package <---$(FORMATRESET)\n"
@echo ""
rm -Rf dist
$(PYTHON_BIN) setup.py sdist
.PHONY: build-package
release: build-package
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Releasing <---$(FORMATRESET)\n"
@echo ""
$(TWINE_BIN) upload dist/*
.PHONY: release
check-release: build-package
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Checking package <---$(FORMATRESET)\n"
@echo ""
$(TWINE_BIN) check dist/*
.PHONY: check-release
tox:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Launching all Tox environments <---$(FORMATRESET)\n"
@echo ""
$(TOX_BIN)
.PHONY: tox
quality: test flake docs check-release freeze-dependencies
@echo ""
@printf "$(FORMATGREEN)$(FORMATBOLD) ♥ ♥ Everything should be fine ♥ ♥ $(FORMATRESET)\n"
@echo ""
.PHONY: quality