forked from chrishayuk/vibe-coding-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
255 lines (206 loc) · 6.33 KB
/
Makefile
File metadata and controls
255 lines (206 loc) · 6.33 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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# Makefile for Python Projects with uv
#
# This Makefile provides common development tasks for Python projects
# using uv as the package manager. All commands use uv run to ensure
# proper environment isolation.
#
# Usage:
# make help Show this help message
# make install Install project dependencies
# make test Run tests with coverage
# make lint Run all code quality checks
# make format Format code automatically
# make clean Clean build artifacts and caches
#
# Variables
PACKAGE_NAME = {{package_name}}
SRC_DIR = src
TEST_DIR = tests
PYTHON_FILES = $(SRC_DIR) $(TEST_DIR)
# Default target
.DEFAULT_GOAL := help
# Help target
.PHONY: help
help: ## Show this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
# Installation targets
.PHONY: install
install: ## Install production dependencies
uv sync
.PHONY: dev-install
dev-install: ## Install all dependencies including dev
uv sync --dev
.PHONY: upgrade
upgrade: ## Upgrade all dependencies to latest versions
uv sync --upgrade
# Testing targets
.PHONY: test
test: ## Run all tests
uv run pytest
.PHONY: test-cov
test-cov: ## Run tests with coverage report
uv run pytest --cov=$(SRC_DIR)/$(PACKAGE_NAME) --cov-report=term-missing --cov-report=html
.PHONY: test-watch
test-watch: ## Run tests in watch mode (requires pytest-watch)
uv run ptw -- --tb=short
.PHONY: test-verbose
test-verbose: ## Run tests with verbose output
uv run pytest -vv
.PHONY: test-failed
test-failed: ## Re-run only failed tests
uv run pytest --lf
# Code quality targets
.PHONY: lint
lint: ## Run all linting checks
uv run ruff check $(PYTHON_FILES)
uv run mypy $(SRC_DIR)
.PHONY: lint-fix
lint-fix: ## Fix auto-fixable linting issues
uv run ruff check $(PYTHON_FILES) --fix
.PHONY: format
format: ## Format code with ruff and black
uv run ruff format $(PYTHON_FILES)
uv run black $(PYTHON_FILES)
.PHONY: format-check
format-check: ## Check code formatting without making changes
uv run ruff format --check $(PYTHON_FILES)
uv run black --check $(PYTHON_FILES)
.PHONY: typecheck
typecheck: ## Run type checking with mypy
uv run mypy $(SRC_DIR)
.PHONY: security
security: ## Run security checks with bandit
uv run bandit -r $(SRC_DIR)
# Pre-commit targets
.PHONY: pre-commit
pre-commit: ## Run pre-commit on all files
uv run pre-commit run --all-files
.PHONY: pre-commit-install
pre-commit-install: ## Install pre-commit hooks
uv run pre-commit install
.PHONY: pre-commit-update
pre-commit-update: ## Update pre-commit hooks to latest versions
uv run pre-commit autoupdate
# Build and distribution targets
.PHONY: build
build: ## Build distribution packages
uv build
.PHONY: publish-test
publish-test: ## Publish to TestPyPI
uv publish --publish-url https://test.pypi.org/legacy/
.PHONY: publish
publish: ## Publish to PyPI (requires authentication)
uv publish
# Documentation targets
.PHONY: docs
docs: ## Build documentation (requires sphinx)
uv run sphinx-build -b html docs docs/_build
.PHONY: docs-serve
docs-serve: ## Serve documentation locally
uv run python -m http.server -d docs/_build 8000
# Development targets
.PHONY: run
run: ## Run the main application
uv run python -m $(PACKAGE_NAME)
.PHONY: shell
shell: ## Open an interactive Python shell
uv run python
.PHONY: ipython
ipython: ## Open IPython shell (requires ipython)
uv run ipython
.PHONY: jupyter
jupyter: ## Start Jupyter notebook (requires jupyter)
uv run jupyter notebook
# Cleaning targets
.PHONY: clean
clean: ## Clean build artifacts and caches
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf .ruff_cache/
rm -rf htmlcov/
rm -rf .coverage
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
find . -type f -name "*~" -delete
.PHONY: clean-all
clean-all: clean ## Clean everything including virtual environment
rm -rf .venv/
rm -rf uv.lock
# CI/CD targets
.PHONY: ci-test
ci-test: ## Run CI test suite
uv run pytest --cov=$(SRC_DIR)/$(PACKAGE_NAME) --cov-report=xml --cov-report=term
.PHONY: ci-lint
ci-lint: ## Run CI linting checks
uv run ruff check $(PYTHON_FILES) --format=github
uv run mypy $(SRC_DIR) --junit-xml mypy-report.xml
# Dependency management targets
.PHONY: deps-add
deps-add: ## Add a new dependency (use with PKG=package-name)
@if [ -z "$(PKG)" ]; then echo "Usage: make deps-add PKG=package-name"; exit 1; fi
uv add $(PKG)
.PHONY: deps-add-dev
deps-add-dev: ## Add a new dev dependency (use with PKG=package-name)
@if [ -z "$(PKG)" ]; then echo "Usage: make deps-add-dev PKG=package-name"; exit 1; fi
uv add --dev $(PKG)
.PHONY: deps-remove
deps-remove: ## Remove a dependency (use with PKG=package-name)
@if [ -z "$(PKG)" ]; then echo "Usage: make deps-remove PKG=package-name"; exit 1; fi
uv remove $(PKG)
.PHONY: deps-show
deps-show: ## Show installed dependencies
uv pip list
.PHONY: deps-outdated
deps-outdated: ## Show outdated dependencies
uv pip list --outdated
.PHONY: deps-tree
deps-tree: ## Show dependency tree
uv pip tree
# Lock file management
.PHONY: lock
lock: ## Update lock file
uv lock
.PHONY: lock-check
lock-check: ## Verify lock file is up to date
uv lock --check
# Environment targets
.PHONY: env-info
env-info: ## Show environment information
@echo "Python version:"
@uv run python --version
@echo "\nPython path:"
@uv run which python
@echo "\nuv version:"
@uv --version
@echo "\nProject dependencies:"
@uv pip list
# Quality assurance targets
.PHONY: qa
qa: lint typecheck test-cov ## Run all quality checks
.PHONY: qa-fix
qa-fix: format lint-fix test ## Fix issues and run tests
# Watch targets for development
.PHONY: watch
watch: ## Watch for changes and run tests
uv run watchmedo shell-command \
--patterns="*.py" \
--recursive \
--command='clear && make test' \
$(PYTHON_FILES)
# Utility targets
.PHONY: check-all
check-all: format-check lint typecheck test-cov ## Run all checks without modifications
.PHONY: ready
ready: format lint-fix typecheck test-cov ## Prepare code for commit
.PHONY: release
release: clean check-all build ## Prepare a release
# Template metadata
# Repository: vibe-coding-templates
# Path: python/templates/Makefile
# Version: 1.0.0
# Date: 2025-01-24