Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
136 lines (116 loc) · 5.49 KB
/
Copy pathMakefile
File metadata and controls
136 lines (116 loc) · 5.49 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
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
PROJECT_NAME = LittleBookOfSemaphores
.PHONY: help create_environment create_environment_dev delete_environment \
update_environment update_environment_dev clean lint format tests serve \
quarto-sync-assets quarto-convert html html-dev html-preview html-preview-dev \
html-publish publish
help:
@echo "Available targets:"
@echo " create_environment - Create conda environment from environment.yml"
@echo " create_environment_dev - Create dev environment (base + pytest/black/flake8)"
@echo " delete_environment - Remove conda environment"
@echo " update_environment - Update environment from environment.yml (with --prune)"
@echo " update_environment_dev - Update dev environment"
@echo " clean - Remove temporary files and caches"
@echo " lint - Run linters (flake8, black --check)"
@echo " format - Format code with black"
@echo " tests - Run Sync tests"
@echo " serve - Static server (open /web/index.html or /web/spike.html)"
@echo " quarto-convert - Regenerate section .qmd files from book/book.tex"
@echo " quarto-sync-assets - Copy Sync embed assets into quarto/assets/sync/"
@echo " html - Sync assets + render full Quarto book → quarto/_book/"
@echo " html-dev - Sync assets + render short TOC (_quarto-dev.yml swap)"
@echo " html-preview - Sync assets + Quarto live preview (full book)"
@echo " html-preview-dev - Sync assets + live preview (short TOC)"
@echo " publish - Push quarto/_book to gh-pages (run html first)"
@echo " html-publish - make html && make publish"
## Set up Python environment
create_environment:
mamba env create -y -f environment.yml
@echo ""
@echo ">>> Environment created successfully!"
@echo ">>> Activate with: conda activate $(PROJECT_NAME)"
## Create dev environment (base + test/lint tools)
create_environment_dev: create_environment
mamba env update -y -f environment-dev.yml --name $(PROJECT_NAME)
@echo ""
@echo ">>> Dev environment created successfully!"
@echo ">>> Activate with: conda activate $(PROJECT_NAME)"
@echo ">>> CI / pip-only equivalent: pip install -r requirements-dev.txt"
## Delete environment
delete_environment:
mamba env remove -y --name $(PROJECT_NAME)
@echo ">>> Environment $(PROJECT_NAME) removed"
## Update environment
update_environment:
mamba env update -y -f environment.yml --name $(PROJECT_NAME) --prune
@echo ">>> Environment updated successfully!"
## Update dev environment
update_environment_dev: update_environment
mamba env update -y -f environment-dev.yml --name $(PROJECT_NAME) --prune
@echo ">>> Dev environment updated successfully!"
## Run tests
tests:
@echo "Running tests..."
cd code && python -m pytest sync_core_test.py Sync_test.py Gui_test.py -q
@echo ">>> Tests complete!"
## Run linters (check only) — Sync engine + tests; not Gui or sync_code examples
lint:
@echo "Running linters..."
flake8 code/sync_core.py code/Sync.py code/sync_core_test.py code/Sync_test.py
black --check --config pyproject.toml code/sync_core.py code/Sync.py code/sync_core_test.py code/Sync_test.py
@echo ">>> Linting complete!"
## Format code
format:
@echo "Formatting code..."
black --config pyproject.toml code/sync_core.py code/Sync.py code/sync_core_test.py code/Sync_test.py
@echo ">>> Formatting complete!"
## Clean temporary files and caches
clean:
@echo "Cleaning temporary files and caches..."
-find . -type f -name "*.py[co]" -delete
-find . -type d -name "__pycache__" -delete
-find . -type d -name ".pytest_cache" -delete
-find . -type d -name ".ipynb_checkpoints" -delete
-rm -rf .ruff_cache/
-rm -rf .mypy_cache/
-rm -rf build/
-rm -rf dist/
-rm -rf *.egg-info
-rm -rf quarto/_book/
-rm -rf quarto/.quarto/
-rm -rf quarto/build/
@echo ">>> Cleanup complete!"
## Local static server for the web app / Pyodide spike
## Open http://localhost:8000/web/index.html (serve repo root for ../code/)
serve:
@echo "Open http://localhost:8000/web/index.html"
python -m http.server 8000
## Regenerate Quarto section pages from LaTeX (Task 27)
quarto-convert:
python3 quarto/scripts/convert_lbs.py
## Copy Sync embed + engine + curated examples into the Quarto tree (Task 23)
quarto-sync-assets:
mkdir -p quarto/assets/sync/examples
cp web/sync_embed.js web/sync_embed.css code/sync_core.py quarto/assets/sync/
cp code/sync_code/mutex.py quarto/assets/sync/examples/
@echo ">>> Quarto Sync assets updated under quarto/assets/sync/"
## Quarto HTML book. Requires Quarto CLI:
## https://quarto.org/docs/get-started/
html: quarto-sync-assets
cd quarto && quarto render
@echo ">>> HTML book: quarto/_book/index.html"
## Short TOC for Sync embed work (Task 32) — edit quarto/_quarto-dev.yml
html-dev: quarto-sync-assets
cd quarto && cp _quarto.yml _quarto.yml.full && cp _quarto-dev.yml _quarto.yml && \
quarto render; status=$$?; mv _quarto.yml.full _quarto.yml; exit $$status
@echo ">>> Dev HTML book: quarto/_book/index.html"
html-preview: quarto-sync-assets
cd quarto && quarto preview
html-preview-dev: quarto-sync-assets
cd quarto && cp _quarto.yml _quarto.yml.full && cp _quarto-dev.yml _quarto.yml && \
quarto preview; status=$$?; mv _quarto.yml.full _quarto.yml; exit $$status
## Publish to GitHub Pages (ThinkJava2 pattern: build locally, push gh-pages)
publish:
cd quarto && quarto publish gh-pages --no-render
@echo ">>> Published to gh-pages branch (enable Pages on the repo if needed)"
html-publish: html publish