-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (52 loc) · 1.86 KB
/
Makefile
File metadata and controls
63 lines (52 loc) · 1.86 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
# ==========================================
# BoolForge tutorial pipeline (src → outputs)
# ==========================================
# Canonical sources
PY_TUTORIALS := $(wildcard tutorials/src/tutorial*.py)
# Generated notebooks (same basename, different folder)
IPYNBS := $(patsubst tutorials/src/%.py,tutorials/%.ipynb,$(PY_TUTORIALS))
# Execution timeout (seconds)
TIMEOUT := 300
.PHONY: tutorials html clean distclean
# ------------------------------------------
# Convert + execute all tutorials
# ------------------------------------------
tutorials: $(IPYNBS)
@echo "✅ All tutorials converted and executed successfully."
# Rule: src/*.py → tutorials/*.ipynb → executed
tutorials/%.ipynb: tutorials/src/%.py
@echo "▶ Converting $< → $@"
jupytext --to notebook $< --output $@
@echo "â–¶ Executing $@"
jupyter nbconvert \
--execute \
--to notebook \
--inplace \
--ExecutePreprocessor.timeout=$(TIMEOUT) \
$@
# ------------------------------------------
# Render HTML previews
# ------------------------------------------
html: tutorials
@echo "â–¶ Rendering HTML previews"
jupyter nbconvert --to html $(IPYNBS)
# ------------------------------------------
# Clean generated artifacts
# ------------------------------------------
clean:
rm -f tutorials/*.html
distclean:
rm -f tutorials/*.ipynb tutorials/*.html
# ------------------------------------------
# Create pdfs
# ------------------------------------------
.PHONY: tutorial_pdfs
tutorial_pdfs:
@mkdir -p tutorials/pdf
@ls tutorials/*.ipynb | xargs -n 1 -P 4 sh -c '\
echo "▶ Converting $$0 → PDF"; \
jupyter nbconvert --to webpdf \
--HTMLExporter.extra_css="[\"pre { white-space: pre-wrap !important; word-break: break-word !important; }\"]" \
--TemplateExporter.exclude_input_prompt=True \
"$$0" --output-dir tutorials/pdf \
'