-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
75 lines (60 loc) · 2.13 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
.PHONY: build-init python-book r-book website github
WEB_DIR=_www
SOURCE_DIR=source
BUILD_NINJA=$(SOURCE_DIR)/build.ninja
PYTHON_BOOK_DIR=python-book
R_BOOK_DIR=r-book
PYTHON ?= python
PIP_INSTALL_CMD ?= $(PYTHON) -m pip install
_submodule-update:
git submodule update --init --recursive
_r-build-requirements:
Rscript -e "source('scripts/install_r_requirements.R')"
_python-build-requirements:
$(PIP_INSTALL_CMD) -r build-requirements.txt
$(BUILD_NINJA): $(SOURCE_DIR)/generate-ninja.py
(cd $(SOURCE_DIR) && $(PYTHON) generate-ninja.py)
ninja-config: ## Configure ninja for source builds
ninja-config: $(BUILD_NINJA)
build-init: ## Install build dependencies
build-init: _submodule-update _r-build-requirements _python-build-requirements
_landing-page:
cd website && make landing-page
python-book: ## Build the Python version of the book
python-book: ninja-config
cd $(SOURCE_DIR) && ninja clean && ninja python-book
$(PYTHON) ./scripts/postprocess_site.py $(SOURCE_DIR)/_quarto-python.yml
python-book-jl: python-book
# Jupyter-lite files for book build.
$(PIP_INSTALL_CMD) -r py-jl-requirements.txt
$(PYTHON) ./scripts/process_notebooks.py \
$(SOURCE_DIR)/_quarto-python.yml \
_py_notebooks
$(PYTHON) -m jupyter lite build \
--contents _py_notebooks \
--output-dir $(PYTHON_BOOK_DIR)/interact \
--lite-dir $(PYTHON_BOOK_DIR)
r-book: ## Build the R version of the book
r-book: ninja-config
cd $(SOURCE_DIR) && ninja clean && ninja r-book
$(PYTHON) ./scripts/postprocess_site.py $(SOURCE_DIR)/_quarto-r.yml
r-book-jl: r-book
$(PIP_INSTALL_CMD) -r r-jl-requirements.txt
$(PYTHON) ./scripts/process_notebooks.py \
$(SOURCE_DIR)/_quarto-r.yml \
_r_notebooks
$(PYTHON) -m jupyter lite build \
--contents _r_notebooks \
--output-dir $(R_BOOK_DIR)/interact \
--lite-dir $(R_BOOK_DIR)
_source-clean:
cd $(SOURCE_DIR) && ninja clean
clean: _source-clean
rm -rf $(PYTHON_BOOK_DIR) $(R_BOOK_DIR) _r_notebooks _py_notebooks
.DEFAULT_GOAL := help
help:
@sed \
-e '/^[a-zA-Z0-9_\-]*:.*##/!d' \
-e 's/:.*##\s*/:/' \
-e 's/^\(.\+\):\(.*\)/$(shell tput setaf 6)\1$(shell tput sgr0):\2/' \
$(MAKEFILE_LIST) | column -c2 -t -s :