This repository has been archived by the owner on Jul 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
143 lines (85 loc) · 3.48 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
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
137
138
139
140
141
142
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
.DEFAULT_GOAL := help
PYTEST_K ?= ""
PYTEST_MARKERS ?= ""
all: npm-build pkg ## Build JS and Python
# ------------------------------------------------------------------------------
# Python
env: ## Create Python env
cd $(CURDIR)/python; poetry install --with dev --with test --with docs
pkg: ## Build package
cd $(CURDIR)/python; poetry build
check: ## Check linting
cd $(CURDIR)/python; isort . --check-only --diff
cd $(CURDIR)/python; black . --check
cd $(CURDIR)/python; flake8
fmt: ## Format source
cd $(CURDIR)/python; isort .
cd $(CURDIR)/python; black .
test-%: ## Run tests
cd $(CURDIR)/python; pytest -k $(PYTEST_K) -m $(subst test-,,$@)
test-all: ## Run all tests
cd $(CURDIR)/python; pytest -k $(PYTEST_K) -m $(PYTEST_MARKERS)
report: ## Generate coverage reports
cd $(CURDIR)/python; coverage xml
cd $(CURDIR)/python; coverage html
upload-pypi: ## Upload package to PyPI
cd $(CURDIR)/python; twine upload dist/*.tar.gz
cleanpython: ## Clean Python build files
cd $(CURDIR)/python; rm -rf .pytest_cache dist
cd $(CURDIR)/python; rm -f .coverage coverage.xml
find . -type f -name '*.py[co]' -delete
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type d -name .ipynb_checkpoints -exec rm -rf {} +
resetpython: cleanpython ## Reset Python
cd $(CURDIR)/python; rm -rf .venv
example: ## Dev: Run nbconvert on one example
cd $(CURDIR)/examples; ILLUSIONIST_DEV_MODE=1 jupyter nbconvert pandas.ipynb --output-dir=$(CURDIR)/docs/examples/ --to illusionist
# ------------------------------------------------------------------------------
# Javascript
npm-install: ## JS: Install dependencies
cd $(CURDIR)/js; npm install
npm-i: npm-install
npm-build: ## JS: Build
cd $(CURDIR)/js; npm run build
npm-dev: ## JS: Build dev mode
cd $(CURDIR)/js; npm run dev
npm-publish: ## JS: Publish to NPM
cd $(CURDIR)/js; npm version
cd $(CURDIR)/js; npm publish
cleanjs: ## JS: Clean build files
cd $(CURDIR)/js; npm run clean
rm -rf $(CURDIR)/python/illusionist/templates/illusionist/assets/*.js*
rm -rf $(CURDIR)/python/illusionist/templates/illusionist/assets/*.css*
resetjs: ## JS: Reset
cd $(CURDIR)/js; npm run reset
# ------------------------------------------------------------------------------
# Docs
docs: ## Docs: Build
$(MAKE) docs-examples-html
mkdocs build
$(MAKE) docs-example-exec-nbs
.PHONY: docs
docs-serve: ## Docs: Serve
mkdocs serve
docs-examples-html: ## Docs: Convert examples to HTML
cd $(CURDIR)/examples; jupyter nbconvert *.ipynb --output-dir=$(CURDIR)/docs/examples/ --to illusionist
docs-example-exec-nbs: ## Docs: Execute examples inplace
cd $(CURDIR)/examples; jupyter nbconvert *.ipynb --output-dir=$(CURDIR)/site/examples/notebooks --to illusionist-nb
examples-clear-output: ## Clear output of notebooks
cd $(CURDIR)/examples; jupyter nbconvert *.ipynb --clear-output --inplace
serve-examples: ## Docs: Serve examples
python -m http.server
# ------------------------------------------------------------------------------
# Other
cleanall: cleanjs cleanpython ## Clean everything
rm -rf site
rm -f $(CURDIR)/examples/*.html
rm -f $(CURDIR)/docs/examples/*.html
help: ## Show this help menu
@grep -E '^[0-9a-zA-Z_-]+:.*?##.*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?##"; OFS="\t\t"}; {printf "\033[36m%-30s\033[0m %s\n", $$1, ($$2==""?"":$$2)}'