-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
214 lines (190 loc) · 7.29 KB
/
Copy pathMakefile
File metadata and controls
214 lines (190 loc) · 7.29 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
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
# Slidedown Development Makefile
#
# Automatically detects Android/Termux and uses appropriate package manager:
# - Android/Termux: uses pip (to avoid "failed to lock" issues)
# - Non-Android: uses uv pip (faster, more reliable)
#
# Quick start:
# make venv - Create virtual environment
# make dev - Install in editable mode with dev dependencies
# make install - Install package
# make test - Run tests
# make lint - Run linters
# make clean - Remove build artifacts
VENV_DIR := .venv
VENV_BIN := $(VENV_DIR)/bin
# Configurable presentation options (can be overridden)
SOURCE ?= examples/watermarked/light-watermarks-demo.sd
THEME ?= conventional-light
PORT ?= 8000
# Parse SOURCE into components for slidedown CLI
# SOURCE: examples/watermarked/light-watermarks-demo.sd
# INPUT_DIR: examples/watermarked
# INPUT_FILE: light-watermarks-demo.sd
# OUTPUT_DIR: output/watermarked
INPUT_DIR := $(dir $(SOURCE))
INPUT_FILE := $(notdir $(SOURCE))
OUTPUT_BASE := output
OUTPUT_SUBDIR := $(patsubst examples/%,%,$(INPUT_DIR))
OUTPUT_DIR := $(OUTPUT_BASE)/$(OUTPUT_SUBDIR)
# Detect Android/Termux environment
IS_ANDROID := $(shell test -d /data/data/com.termux || test -n "$$ANDROID_ROOT" && echo 1 || echo 0)
# Set package installer based on platform
ifeq ($(IS_ANDROID),1)
PIP := $(VENV_BIN)/pip
PLATFORM_MSG := "Android/Termux detected - using pip"
else
PIP := uv pip
PLATFORM_MSG := "Non-Android detected - using uv pip"
endif
.PHONY: help venv dev install test lint format typecheck clean purge shell
.PHONY: compile serve presentation readme-presentation
.PHONY: build publish publish-test
help:
@echo "Slidedown development targets:"
@echo ""
@echo "Setup:"
@echo " make venv - Create virtual environment"
@echo " make dev - Install in editable mode with dev dependencies"
@echo " make install - Install package (production)"
@echo ""
@echo "Development:"
@echo " make presentation - Compile and serve presentation (see variables below)"
@echo " make compile - Compile presentation only"
@echo " make serve - Serve compiled presentation only"
@echo " make readme-presentation - Compile README presentation source"
@echo " make shell - Start shell with activated virtual environment"
@echo ""
@echo "Variables (override with: make compile SOURCE=myfile.sd THEME=dark):"
@echo " SOURCE=$(SOURCE)"
@echo " THEME=$(THEME)"
@echo " OUTPUT_DIR=$(OUTPUT_DIR) (auto-derived from SOURCE)"
@echo " PORT=$(PORT)"
@echo ""
@echo "Auto-Derivation:"
@echo " OUTPUT_DIR is automatically derived from SOURCE path:"
@echo " examples/watermarked/demo.sd -> output/watermarked/"
@echo " examples/something/talk.sd -> output/something/"
@echo " You only need to specify SOURCE, OUTPUT_DIR adapts automatically!"
@echo ""
@echo "Testing & QA:"
@echo " make test - Run pytest"
@echo " make lint - Run ruff linter"
@echo " make format - Run black formatter"
@echo " make typecheck - Run mypy type checker"
@echo ""
@echo "Publishing:"
@echo " make build - Build sdist + wheel into dist/"
@echo " make publish-test - Upload to TestPyPI (dry-run)"
@echo " make publish - Upload to PyPI (requires ~/.pypirc or TWINE_* env vars)"
@echo ""
@echo "Cleanup:"
@echo " make clean - Remove build artifacts"
@echo " make purge - Remove build artifacts AND virtual environment"
@echo ""
@echo "Example Workflow:"
@echo " Let's say you have a new slidedown called 'myDeck.sd' and it is"
@echo " located in examples/myDeck/myDeck.sd -- in order to set everything"
@echo " up and serve the presentation you do:"
@echo ""
@echo " 1. Setup from scratch (first time only):"
@echo " make dev"
@echo ""
@echo " 2. Compile and serve your presentation:"
@echo " make presentation SOURCE=examples/myDeck/myDeck.sd"
@echo ""
@echo " This will automatically:"
@echo " - Use the virtual environment (no need to activate manually)"
@echo " - Compile examples/myDeck/myDeck.sd with theme $(THEME)"
@echo " - Output to output/myDeck/ (auto-derived)"
@echo " - Serve on http://localhost:$(PORT)"
@echo ""
@echo " Note: 'make' targets automatically use the venv, no activation needed!"
@echo ""
@echo "Platform: $(PLATFORM_MSG)"
venv:
test -d $(VENV_DIR) || python3 -m venv $(VENV_DIR)
@echo "Virtual environment created. Activate with: source $(VENV_BIN)/activate"
@echo "Platform: $(PLATFORM_MSG)"
dev: venv
@echo "Installing slidedown in editable mode..."
@echo "Platform: $(PLATFORM_MSG)"
ifeq ($(IS_ANDROID),1)
@echo "Android/Termux detected - installing without dev dependencies (no ruff/black/mypy)"
@echo "This may take several minutes as some packages compile from source..."
$(PIP) install -e .
@echo ""
@echo "SUCCESS: Slidedown core installed (skipped dev tools: ruff, black, mypy, pytest)"
@echo "These tools require additional Rust compilation and are not needed for basic usage"
else
$(PIP) install -e ".[dev]"
@echo "Installed slidedown in editable mode with dev dependencies"
endif
install: venv
@echo "Installing slidedown..."
@echo "Platform: $(PLATFORM_MSG)"
$(PIP) install .
@echo "Installed slidedown"
test:
$(VENV_BIN)/pytest -v
lint:
$(VENV_BIN)/ruff check .
format:
$(VENV_BIN)/black .
typecheck:
$(VENV_BIN)/mypy src
compile:
@echo "Compiling $(SOURCE) with theme $(THEME)..."
@echo " Input dir: $(INPUT_DIR)"
@echo " Input file: $(INPUT_FILE)"
@echo " Output dir: $(OUTPUT_DIR)"
$(VENV_BIN)/slidedown $(INPUT_DIR) $(OUTPUT_BASE) \
--inputFile $(INPUT_FILE) \
--outputSubdir $(OUTPUT_SUBDIR) \
--theme $(THEME)
@echo "Compiled to $(OUTPUT_DIR)/"
serve:
@echo "Serving presentation on http://localhost:$(PORT)"
@echo "Press Ctrl+C to stop"
cd $(OUTPUT_DIR) && python3 -m http.server $(PORT)
presentation: compile serve
readme-presentation:
@echo "Compiling docs/readme-presentation.sd to presentation..."
$(VENV_BIN)/slidedown docs docs-temp \
--inputFile readme-presentation.sd \
--theme conventional-light
@echo "Updating docs/readme-presentation/..."
rm -rf docs/readme-presentation/*
cp -r docs-temp/* docs/readme-presentation/
rm -rf docs-temp
@echo "✓ README presentation updated in docs/readme-presentation/"
@echo " View locally: open docs/readme-presentation/index.html"
@echo " Or commit and push to update GitHub Pages"
build:
@echo "Building source distribution and wheel..."
$(VENV_BIN)/pip install --quiet build
$(VENV_BIN)/python -m build
@echo "Artifacts in dist/:"
@ls -lh dist/
publish-test: build
@echo "Uploading to TestPyPI (https://test.pypi.org)..."
$(VENV_BIN)/pip install --quiet twine
$(VENV_BIN)/twine upload --repository testpypi dist/*
@echo "Install from TestPyPI with:"
@echo " pip install --index-url https://test.pypi.org/simple/ slidedown"
publish: build
@echo "Uploading to PyPI..."
$(VENV_BIN)/pip install --quiet twine
$(VENV_BIN)/twine upload dist/*
@echo "Install with: pip install slidedown"
clean:
rm -rf build/ dist/ *.egg-info .mypy_cache .pytest_cache
rm -rf output/
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
@echo "Cleaned build artifacts"
purge: clean
rm -rf $(VENV_DIR)
@echo "Removed virtual environment"
shell: venv
@echo "Starting shell with activated venv (exit to return)..."
@bash -c "source $(VENV_BIN)/activate && exec bash"