-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·79 lines (61 loc) · 2.47 KB
/
Makefile
File metadata and controls
executable file
·79 lines (61 loc) · 2.47 KB
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
notebooks := 01-generalites.ipynb \
02-langage.ipynb \
03-langage.ipynb \
04-numpy.ipynb \
05-microprojet.ipynb \
06-langage.ipynb \
07-pandas.ipynb \
local_reveal := False
ifeq ($(local_reveal),True)
# Useful for running in local with internet connexion
revealprefix := "reveal.js"
else
# Needed for online publication by gitlab pages
revealprefix := "https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.3.0"
endif
html := $(addprefix build/, $(subst .ipynb,.html,$(notebooks)))
slides := $(addprefix build/, $(subst .ipynb,.slides.html,$(notebooks)))
executed_notebooks := $(addprefix build/, $(notebooks))
archives := $(addprefix build/, $(subst .ipynb,.zip,$(notebooks)))
.PHONY: all clean html slides executed_notebooks index copy_to_build pdf archives
all: build html slides index archives pdf
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " slides to make slideshows (use local_reveal=True \
to run them without internet connection)"
@echo " pdf to compile all notebooks as a single PDF book"
@echo " archives to make ##-notebook.zip files"
@echo "Use \`make' to run all these targets"
executed_notebooks: copy_to_build $(executed_notebooks)
html: copy_to_build $(html)
slides: copy_reveal $(slides)
index: copy_to_build build/index.html
pdf: copy_to_build build/cours-python.pdf
archives: build $(archives)
define nbconvert
jupyter nbconvert --to $(1) $< --output-dir=build
endef
build:
@mkdir -p build
copy_to_build: build
rsync -ra --delete fig build/ --exclude ".*/" --exclude "__pycache__"
rsync -ra --delete exos build/ --exclude ".*/" --exclude "__pycache__"
copy_reveal: build
rsync -ra --delete reveal.js build/
$(executed_notebooks): build/%.ipynb: %.ipynb
$(call nbconvert,notebook,$<) --execute --allow-errors --ExecutePreprocessor.timeout=60
build/%.html: build/%.ipynb
$(call nbconvert,html,$<)
build/%.slides.html: build/%.ipynb
$(call nbconvert,slides,$<) --reveal-prefix $(revealprefix)
build/index.html: index.ipynb
$(call nbconvert,html,$<)
build/cours-python.tex: executed_notebooks book.tplx
cd build && python3 -m bookbook.latex --output-file cours-python --template ../book.tplx
build/cours-python.pdf: executed_notebooks book.tplx
cd build && python3 -m bookbook.latex --pdf --output-file cours-python --template ../book.tplx
build/%.zip: %.ipynb
zip -r $@ $< fig exos --exclude "*/\.*" "*__pycache__*"
clean:
rm -rf build