-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (60 loc) · 2.35 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
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line
PYTHON = python3.8
SPHINXOPTS =
SPHINXBUILD = ./.venv/bin/sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help: ensurevenv
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@echo "---"
@echo " bumpdeps to bump dependencies in requirement files."
@echo " compiledeps to update requirements.txt files to adhere to dependencies"
@echo " declared in requirements.in files (with minimal version changes)."
@echo " livehtml to serve dirhtml documentation locally and auto-build on changes."
.PHONY: help bumpdeps compiledeps ensurevenv livehtml Makefile
# Note to whoever sees this in future:
# Using indentation before `ensurevenv` lines breaks this target
ifeq ($(wildcard ./.venv/.),)
ensurevenv: newenv
else
ensurevenv: syncenv
endif
newenv:
@echo "- Setting up the virtual environment"
$(PYTHON) -m venv .venv
@echo "- Installing requirements into venv"
./.venv/bin/python -m pip install -r requirements.txt -r dev-requirements.txt
@echo
@echo "- Installing pre-commit hook"
./.venv/bin/pre-commit install
@echo
syncenv:
@echo "- Synchronizing requirements in venv"
./.venv/bin/python -m piptools sync requirements.txt dev-requirements.txt
@echo
ensurevenv: ;
bumpdeps: ensurevenv
@echo "- Upgrading requirement files"
./.venv/bin/pip-compile --quiet --upgrade
./.venv/bin/pip-compile --quiet --upgrade dev-requirements.in
$(MAKE) aftercompiledeps
compiledeps: ensurevenv
@echo "- Compiling requirement files"
./.venv/bin/pip-compile --quiet
./.venv/bin/pip-compile --quiet dev-requirements.in
$(MAKE) aftercompiledeps
aftercompiledeps:
-./.venv/bin/pre-commit run mixed-line-ending --files requirements.txt dev-requirements.txt >/dev/null
git diff -U1 -- ./requirements.txt ./dev-requirements.txt
@echo
$(MAKE) ensurevenv
livehtml: ensurevenv
./.venv/bin/sphinx-autobuild -b dirhtml -d "$(BUILDDIR)/doctrees" "$(SOURCEDIR)" "$(BUILDDIR)/dirhtml" $(SPHINXOPTS) $(O)
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile ensurevenv
@echo "- Building documentation"
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)