-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
143 lines (127 loc) · 4.26 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
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
COOKIECUTTER_BIN=$(VENV_PATH)/bin/cookiecutter
TOX_BIN=$(VENV_PATH)/bin/tox
SPHINX_RELOAD_BIN=$(PYTHON_BIN) docs/sphinx_reload.py
MAKEFILE_PARSER_BIN=$(PYTHON_BIN) docs/makefile_parser.py
# 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-pycache -- to remove all __pycache__, this is recursive from current directory"
@echo " clean-install -- to clean Python side installation"
@echo " clean-doc -- to remove documentation builds"
@echo " clean-dist -- to remove distributed directory"
@echo
@echo " Installation"
@echo " ============"
@echo
@echo " install -- to install this project with virtualenv and Pip"
@echo
@echo " Usage"
@echo " ====="
@echo
@echo " project -- to create a new project"
@echo
@echo " Documentation"
@echo " ============="
@echo
@echo " docs -- to build documentation"
@echo " livedocs -- to run livereload server to rebuild documentation on source changes"
@echo
@echo " Quality"
@echo " ======="
@echo
@echo " flake8 -- to check codestyle on cookie internals"
@echo " template-flake8 -- to check codestyle on project template (it is expected to fail because of Jinja syntax in some files)"
@echo " tox -- to use Tox to create, install and test the cookiecutter with different options"
@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
.PHONY: clean-pycache
clean-install:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Clear installation <---$(FORMATRESET)\n"
@echo ""
rm -Rf $(VENV_PATH)
.PHONY: clean-install
clean-doc:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Clear documentation <---$(FORMATRESET)\n"
@echo ""
rm -Rf docs/_build
.PHONY: clean-doc
clean-dist:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Cleaning distributed directory <---$(FORMATRESET)\n"
@echo ""
rm -Rf dist
.PHONY: clean-dist
clean: clean-install clean-doc 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 -r requirements/base.txt -r requirements/dev.txt -r requirements/docs.txt -r requirements/docs-live.txt
.PHONY: install
docs:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Building documentation <---$(FORMATRESET)\n"
@echo ""
$(MAKEFILE_PARSER_BIN) "{{cookiecutter.package_name}}/Makefile" --format rst --destination docs/_static/makefile_help.rst
cd docs && make html
.PHONY: docs
livedocs:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Watching documentation sources <---$(FORMATRESET)\n"
@echo ""
$(SPHINX_RELOAD_BIN)
.PHONY: livedocs
project:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Creating new project <---$(FORMATRESET)\n"
@echo ""
@mkdir -p dist
@$(COOKIECUTTER_BIN) -o dist .
.PHONY: project
flake8:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Checking codestyle on cookie internals <---$(FORMATRESET)\n"
@echo ""
@$(FLAKE_BIN) --statistics --show-source hooks
.PHONY: flake8
template-flake8:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Checking codestyle on project template <---$(FORMATRESET)\n"
@echo ""
@$(FLAKE_BIN) --statistics --show-source \{\{\cookiecutter.project_name\}\}
.PHONY: template-flake8
tox:
@echo ""
@printf "$(FORMATBLUE)$(FORMATBOLD)---> Create, install and test project with Tox environments <---$(FORMATRESET)\n"
@echo ""
$(TOX_BIN) run
.PHONY: tox