-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile
More file actions
237 lines (210 loc) · 7.1 KB
/
Makefile
File metadata and controls
237 lines (210 loc) · 7.1 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
.PHONY: help clean install dev-install test test-examples test-cov test-integration lint format format-check check build sdist wheel docs html clean-docs upload upload-test check-package setup-venv pre-commit-install pre-commit-run pre-commit-update sync-models
# Use uv if available, otherwise fall back to pip
UV := $(shell command -v uv 2>/dev/null)
ifeq ($(UV),)
PIP_CMD = pip
PYTHON_CMD = python
else
PIP_CMD = uv pip
PYTHON_CMD = uv run python
# dev group is installed by default with uv sync
UV_SYNC = uv sync --group docs --all-extras
endif
help:
@echo "Available targets:"
@echo ""
@echo "Setup (run first):"
@echo " dev-install - Install package with development dependencies (recommended for active development)"
@echo " setup-venv - Create virtual environment and install dependencies only (no package install)"
@echo " Use for: CI/CD, code review, or when you don't need to import the package"
@echo " install - Install the package (after setup-venv or standalone)"
@echo ""
@echo "Pre-commit:"
@echo " pre-commit-install - Install pre-commit hooks"
@echo " pre-commit-run - Run all pre-commit hooks manually"
@echo " pre-commit-update - Update pre-commit hooks to latest versions"
@echo ""
@echo "Testing:"
@echo " test - Run all unit tests in parallel (excludes integration tests)"
@echo " test-examples - Run example script tests"
@echo " test-cov - Run tests with coverage report in parallel"
@echo " test-integration - Run all integration tests in parallel (requires external services)"
@echo ""
@echo "Code Quality:"
@echo " lint - Run linting checks (ruff)"
@echo " format - Format code with ruff"
@echo " format-check - Check code formatting"
@echo " check - Run all checks (lint + format check + tests)"
@echo ""
@echo "Building:"
@echo " build - Build source and wheel distributions"
@echo " sdist - Build source distribution"
@echo " wheel - Build wheel distribution"
@echo " check-package - Check package before uploading"
@echo ""
@echo "Publishing:"
@echo " upload - Upload package to PyPI (requires PYPI_TOKEN env var)"
@echo " upload-test - Upload package to TestPyPI (requires TEST_PYPI_TOKEN env var)"
@echo ""
@echo "Documentation:"
@echo " docs - Build documentation"
@echo " html - Build HTML documentation"
@echo ""
@echo "Data Sync:"
@echo " sync-models - Sync models.json from models.dev"
@echo ""
@echo "Cleanup:"
@echo " clean - Clean build artifacts"
@echo " clean-docs - Clean documentation build"
@echo ""
@if [ -n "$(UV)" ]; then \
echo "Using uv for dependency management"; \
else \
echo "Using pip for dependency management (consider installing uv: curl -LsSf https://astral.sh/uv/install.sh | sh)"; \
fi
@echo ""
@echo "Note: For active development, run 'make dev-install' (installs package + deps)."
@echo " For CI/tools only, run 'make setup-venv' (deps only, no package)."
setup-venv:
@echo "Setting up virtual environment and installing dependencies (without installing package)..."
@echo "This is useful for CI/CD, code review, or when you only need development tools."
@if [ -n "$(UV)" ]; then \
uv sync --group docs --all-extras --no-install-project; \
echo "✅ Virtual environment created and dependencies installed!"; \
echo " To install the package later, run: make install"; \
echo " Note: Some tests may fail without the package installed."; \
else \
echo "Error: uv is required for setup-venv. Install uv or use 'make dev-install' instead."; \
exit 1; \
fi
install:
@if [ -n "$(UV)" ]; then \
uv sync; \
else \
$(PIP_CMD) install -e .; \
fi
dev-install:
@echo "Installing package with all development dependencies..."
@if [ -n "$(UV)" ]; then \
uv sync --group docs --all-extras; \
else \
$(PIP_CMD) install -e ".[dev]"; \
fi
@echo "✅ Package and dependencies installed! Ready for development."
test:
$(PYTHON_CMD) -m pytest tests/ -v -m "not integration" -n auto
test-examples:
$(PYTHON_CMD) -m pytest tests/ -v -m example --no-cov
test-cov:
$(PYTHON_CMD) -m pytest tests/ -m "not integration" --cov=lexilux --cov-report=html --cov-report=term -n auto
test-integration:
@echo "Running integration tests (requires external services)..."
$(PYTHON_CMD) -m pytest tests/ -v -m integration
lint:
$(PYTHON_CMD) -m ruff check lexilux/ tests/ examples/ --output-format=concise --no-fix
format:
$(PYTHON_CMD) -m ruff format lexilux/ tests/ examples/
format-check:
$(PYTHON_CMD) -m ruff format --check lexilux/ tests/ examples/
check: lint format-check test
@echo "All checks passed!"
build: clean
@if [ -n "$(UV)" ]; then \
uv sync --group docs --all-extras; \
fi
$(PYTHON_CMD) -m build
sdist: clean
@if [ -n "$(UV)" ]; then \
uv sync --group docs --all-extras; \
fi
$(PYTHON_CMD) -m build --sdist
wheel: clean
@if [ -n "$(UV)" ]; then \
uv sync --group docs --all-extras; \
fi
$(PYTHON_CMD) -m build --wheel
check-package: build
@echo "Checking package..."
@if [ -n "$(UV)" ]; then \
uv pip install twine; \
else \
$(PIP_CMD) install twine; \
fi
twine check dist/*
upload: check-package
@echo "Uploading to PyPI..."
@if [ -z "$$PYPI_TOKEN" ]; then \
echo "Error: PYPI_TOKEN environment variable is not set."; \
echo "Usage: PYPI_TOKEN=your-token make upload"; \
exit 1; \
fi
@if [ -n "$(UV)" ]; then \
uv pip install twine; \
else \
$(PIP_CMD) install twine; \
fi
twine upload dist/* \
--username __token__ \
--password $$PYPI_TOKEN
upload-test: check-package
@echo "Uploading to TestPyPI..."
@if [ -z "$$TEST_PYPI_TOKEN" ]; then \
echo "Error: TEST_PYPI_TOKEN environment variable is not set."; \
echo "Usage: TEST_PYPI_TOKEN=your-token make upload-test"; \
exit 1; \
fi
@if [ -n "$(UV)" ]; then \
uv pip install twine; \
else \
$(PIP_CMD) install twine; \
fi
twine upload dist/* \
--repository testpypi \
--username __token__ \
--password $$TEST_PYPI_TOKEN
docs: clean-docs
cd docs && make html
html: clean-docs
cd docs && make html
clean:
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
rm -rf .pytest_cache
rm -rf .mypy_cache
find . -type d -name __pycache__ -exec rm -r {} +
find . -type f -name "*.pyc" -delete
@if [ -n "$(UV)" ]; then \
echo "Note: To clean uv virtual environment, run: uv venv --clear"; \
fi
clean-docs:
cd docs && make clean
pre-commit-install:
@echo "Installing pre-commit hooks..."
@if [ -n "$(UV)" ]; then \
uv sync --group dev; \
uv run pre-commit install; \
else \
$(PIP_CMD) install pre-commit; \
pre-commit install; \
fi
@echo "✅ Pre-commit hooks installed!"
pre-commit-run:
@echo "Running all pre-commit hooks..."
@if [ -n "$(UV)" ]; then \
uv run pre-commit run --all-files; \
else \
pre-commit run --all-files; \
fi
pre-commit-update:
@echo "Updating pre-commit hooks..."
@if [ -n "$(UV)" ]; then \
uv run pre-commit autoupdate; \
else \
pre-commit autoupdate; \
fi
@echo "✅ Pre-commit hooks updated!"
sync-models:
@echo "Syncing models.json from models.dev..."
@curl -sL "https://models.dev/api.json" -o lexilux/data/models.json
@echo "✅ models.json synced!"