-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
227 lines (173 loc) · 7.88 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#################################################################################
# GLOBALS #
#################################################################################
PROJECT_NAME = gatpack
PYTHON_VERSION = 3.12
PYTHON_INTERPRETER = python
DOCS_PORT ?= 8000
# .PHONY: w-example
# example: ## Run example code
# weasyprint ./example/report.html ./example/test.pdf
# .PHONY: w-compile
# compile: ## Run compilation code
# weasyprint ./user/02_web/cover.html ./user/03_pdf/cover-test.pdf
.PHONY: build
build: clean ## Builds the python project into a binary with pyinstaller.
pyinstaller gatpack/main.py \
--name GatPack \
--add-data "$(shell python -c 'import cookiecutter; from pathlib import Path; print(Path(cookiecutter.__file__).parent/"VERSION.txt")')":cookiecutter/ \
--icon=docs/images/icon.icns \
--console \
.PHONY: docker-recording-studio
docker-recording-studio: ## Build and run the recording-studio Docker container
docker build -t gatpack-recording-studio -f docker/recording-studio.Dockerfile .
docker run -it --rm -v $(PWD):/app gatpack-recording-studio
.PHONY: gatpack
gatpack: ## Run gatpack cli
echo "HELLO"
.PHONY: schema
schema: ## Generate GatPackCompose JSON schema
python ./gatpack/schema/generate_json_schema.py
.PHONY: test-root
test-root: ## Tests the gatpack root functionality (infer)
gatpack --from ./tests/root/test-tex-jinja.jinja.tex \
-o ./tests/root/test-tex-jinja.tex
.PHONY: test-init
test-init: ## Run gatpack init
cookiecutter "https://github.com/GatlenCulp/cookiecutter-gatpack" --checkout "dev"
.PHONY: test-render
test-render: ## Run gatpack render
# gatpack render ./tests/test.jinja.tex ./tests/test.tex
# rm ./user/01_templates/cover-test.tex
# Test Standard Jinja Rendering
cd ./tests/render && rm -f test-standard-jinja.tex && \
gatpack render test-standard-jinja.jinja.tex \
test-standard-jinja.tex \
compose.gatpack.json
# Test Special Jinja Rendering
cd ./tests/render && rm -f test-tex-jinja.tex && \
gatpack render test-tex-jinja.jinja.tex \
test-tex-jinja.tex compose.gatpack.json \
--no-use-standard-jinja
.PHONY: test-combine
test-combine: ## Run gatpack render
# rm ./user/01_templates/cover-test.tex
# gatpack combine ./tests/test.pdf ./tests/test.pdf ./tests/test-combine.pdf
gatpack combine ./tests/combine/glob/test-*.pdf ./tests/combine/glob/test-glob-combine.pdf
.PHONY: test-build
test-build: ## Run gatpack build
# rm ./user/01_templates/cover-test.tex
gatpack build ./tests/test.tex ./tests/test-build.pdf
# cd tests && pdflatex test-build.tex -interaction=nonstopmode -halt-on-error
.PHONY: test-footer
test-footer: ## Run gatpack footer
# gatpack footer ./tests/footer/test-no-footer.pdf "Page n of N" ./tests/footer/test-footer.pdf
gatpack footer ./tests/footer/test-no-footer.pdf ./tests/footer/test-footer.pdf --text '{n} of {N}' --overwrite
.PHONY: test-infer
test-infer: ## Run gatpack infer
rm -f ./tests/infer/test.tex
gatpack infer --overwrite \
./tests/infer/test.jinja.tex \
./tests/infer/test.pdf
.PHONY: test-root
test-root: ## Run gatpack with no subcommand (ie: infer)
rm -f ./tests/infer/test.tex
gatpack --overwrite \
--from ./tests/infer/test.jinja.tex \
--to ./tests/infer/test.pdf
#################################################################################
# UTILITIES #
#################################################################################
_prep: ## Clean up .DS_Store files
rm -f **/*/.DS_store
_welcome: ## Print a Welcome screen
curl -s https://raw.githubusercontent.com/GatlenCulp/gatlens-opinionated-template/vscode-customization/welcome.txt
#################################################################################
# PACKAGE COMMANDS #
#################################################################################
.PHONY: create_environment
create_environment: ## Set up python interpreter environment
uv venv
@echo ">>> New virtualenv with uv created. Activate with:\nsource '.venv/bin/activate'"
.PHONY: requirements
requirements: ## Install Python Dep
uv sync
.PHONY: publish-all
publish-all: format lint publish docs-publish ## Run format, lint, publish package and docs
#################################################################################
# CLEAN COMMANDS #
#################################################################################
.PHONY: clean
clean: ## Delete all compiled Python files
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
.PHONY: lint ## Lint using ruff (use `make format` to do formatting)
lint:
ruff check --config pyproject.toml gatpack
.PHONY: format ## Format source code with black
format:
ruff --config pyproject.toml gatpack
#################################################################################
# DOCS COMMANDS #
#################################################################################
# Switched to using uv
docs-serve: ## Serve documentation locally on port $(DOCS_PORT)
cd docs && \
mkdocs serve -a localhost:$(DOCS_PORT) || \
echo "\n\nInstance found running on $(DOCS_PORT), try killing process and rerun."
# Makes sure docs can be served prior to actually deploying
docs-publish: ## Build and deploy documentation to GitHub Pages
cd docs && \
mkdocs build && \
mkdocs gh-deploy --clean
#################################################################################
# DATA COMMANDS #
#################################################################################
#################################################################################
# TEST COMMANDS #
#################################################################################
.PHONY: test
test: _prep ## Run all tests
pytest -vvv --durations=0
.PHONY: test-fastest
test-fastest: _prep ## Run tests with fail-fast option
pytest -vvv -FFF
# Requires pytest-watcher (Continuous Testing for Fast Tests)
.PHONY: test-continuous
test-continuous: _prep ## Run tests in watch mode using pytest-watcher
ptw . --now --runner pytest --config-file pyproject.toml -vvv -FFF
.PHONY: test-debug-last
test-debug-last: ## Debug last failed test with pdb
pytest --lf --pdb
.PHONY: _clean_manual_test
_clean_manual_test:
rm -rf manual_test
.PHONY: manual_test
manual_test: _clean_manual_test
rm -rf manual_test
mkdir -p manual_test && cd manual_test && \
gatpack init
#################################################################################
# PROJECT RULES #
#################################################################################
.PHONY: data ## Make Dataset
data: requirements
$(PYTHON_INTERPRETER) gatpack/dataset.py
#################################################################################
# Self Documenting Commands #
#################################################################################
.PHONY: _print-logo
_print-logo: ## Prints the GOTem logo
@echo "\033[38;5;39m ____ ___ _____"
@echo " / ___|/ _ \_ _|__ _ __ ___"
@echo " | | _| | | || |/ _ \ '_ \` _ \\"
@echo " | |_| | |_| || | __/ | | | | |"
@echo " \____|\___/ |_|\___|_| |_| |_|\033[0m"
.PHONY: help
help: _print-logo ## Show this help message
@echo "\n\033[1m~ Available rules: ~\033[0m\n"
@echo "For VSCode/Cursor, try: ⇧ ⌘ P, Tasks: Run Task\n"
@grep -E '^[a-zA-Z][a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[38;5;222m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: all
all: help
.DEFAULT_GOAL := all