Skip to content

Instantly share code, notes, and snippets.

@natsukium
Created November 17, 2020 14:43
Show Gist options
  • Save natsukium/23cf7726489a500fd8700f2436ebb64d to your computer and use it in GitHub Desktop.
Save natsukium/23cf7726489a500fd8700f2436ebb64d to your computer and use it in GitHub Desktop.
py2html with jupytext and nbconvert
NOTEDIR := src/notebooks
NOTESRC := $(wildcard $(NOTEDIR)/*.py)
HTML := $(addprefix outputs/, $(notdir $(NOTESRC:%.py=%.html)))
JUPYTEXT := poetry run jupytext --to notebook
NBCONVERT := poetry run jupyter nbconvert --to html
.PRECIOUS: %.ipynb
.PHONY: html
html: outputs/timestamp
outputs/timestamp: $(HTML)
touch $@
outputs/%.html: src/notebooks/%.ipynb
$(NBCONVERT) $^ --output-dir outputs
%.ipynb: %.py
$(JUPYTEXT) --set-kernel python3 --execute $^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment