Repository navigation
Expand file tree
/
Copy pathmakefile
More file actions
293 lines (239 loc) · 9.74 KB
/
Copy pathmakefile
File metadata and controls
293 lines (239 loc) · 9.74 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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# ============================================
# ProFiles Makefile - Enhanced Version
# ============================================
# Variables
UV := uv
PYTHON := $(UV) run python
PYTEST := $(UV) run pytest
PYLINT := $(UV) run pylint
RUFF := $(UV) run ruff
PYRIGHT := $(UV) run pyright
BRIEFCASE := $(UV) run briefcase
# ============================================
# Installation
# ============================================
.PHONY: install install-system install-system-dev uninstall install-uv install-poetry briefcase-dev briefcase-build briefcase-run briefcase-package briefcase-package-windows briefcase-package-macos briefcase-package-linux-deb briefcase-package-local briefcase-clean
install: ## Install with uv (recommended)
@echo "📦 Installing ProFiles with uv..."
$(UV) sync
@echo "✅ Installation complete!"
install-system: ## Install system-wide (standard mode)
@echo "📦 Installing ProFiles system-wide (standard mode)..."
pip install .
@echo "✅ System installation complete!"
install-system-dev: ## Install system-wide (development mode)
@echo "📦 Installing ProFiles system-wide (development mode)..."
rm -rf src/profiles.egg-info
pip install -e ".[dev]"
@echo "✅ Development installation complete!"
uninstall: ## Uninstall ProFiles from system-wide installation
@echo "🗑️ Uninstalling ProFiles..."
pip uninstall -y profiles-app
@echo "✅ Uninstallation complete!"
install-uv: ## Install uv package manager
@echo "🔧 Installing uv package manager..."
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
@echo "✅ uv installed! Restart your terminal to use it."
install-poetry: ## Install poetry if not present
@echo "🔧 Installing poetry..."
powershell -ExecutionPolicy ByPass -c "irm https://install.python-poetry.org | python -"
@echo "✅ poetry installed! Restart your terminal to use it."
# ============================================
# Briefcase Native Installer
# ============================================
briefcase-dev: ## Run the app from source via Briefcase
@echo "🚀 Running ProFiles in dev mode (Briefcase)..."
$(BRIEFCASE) dev
briefcase-build: ## Build the platform-native Briefcase app bundle
@echo "🔨 Building native bundle via Briefcase..."
$(BRIEFCASE) build
briefcase-run: ## Run the built Briefcase app bundle
@echo "▶️ Running Briefcase-built bundle..."
$(BRIEFCASE) run
briefcase-package: ## Package the native installer (.msi / .dmg / .deb)
@echo "📦 Packaging native installer via Briefcase..."
$(BRIEFCASE) package
briefcase-clean: ## Remove Briefcase build artifacts
@echo "🧹 Cleaning Briefcase artifacts..."
rm -rf build dist
@echo "✅ Briefcase artifacts removed!"
# Host detection for local packaging dispatch (Briefcase cannot cross-compile)
ifeq ($(OS),Windows_NT)
HOST_PKG := briefcase-package-windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
HOST_PKG := briefcase-package-macos
else
HOST_PKG := briefcase-package-linux-deb
endif
endif
briefcase-package-windows: ## Package the Windows installer (.msi) — Windows host only
@echo "📦 Packaging Windows MSI (requires Windows host)..."
$(BRIEFCASE) package windows -p msi
@echo "✅ Installer written to dist/"
briefcase-package-macos: ## Package the macOS disk image (.dmg) — macOS host only
@echo "📦 Packaging macOS DMG (requires macOS host)..."
$(BRIEFCASE) package macos -p dmg
@echo "✅ Installer written to dist/"
briefcase-package-linux-deb: ## Package the Linux .deb — Linux host only
@echo "📦 Packaging Linux .deb (requires Linux host)..."
$(BRIEFCASE) package linux -p deb
@echo "✅ Package written to dist/"
briefcase-package-local: ## Package for the current host OS (auto-detect)
@echo "📦 Detected host package target: $(HOST_PKG)"
$(MAKE) $(HOST_PKG)
# ============================================
# Testing
# ============================================
.PHONY: test test-verbose test-report
test: ## Run tests with coverage
@echo "🧪 Running tests with coverage..."
$(PYTEST) --cov
@echo "✅ Tests complete!"
test-verbose: ## Run tests with detailed output
@echo "🧪 Running tests with detailed output..."
$(PYTEST) --cov -v
@echo "✅ Tests complete!"
test-report: ## Generate detailed HTML coverage report
@echo "📊 Generating detailed coverage report..."
$(PYTEST) --cov --cov-report=html:htmlcov --cov-report=xml
@echo "✅ Coverage report generated!"
@echo "📁 HTML report: htmlcov/index.html"
@echo "📁 XML report: coverage.xml"
# ============================================
# Quality Checks
# ============================================
.PHONY: lint lint-check format format-check typecheck pylint
lint: ## Fix linting issues automatically
@echo "🔍 Fixing linting issues..."
$(RUFF) check --fix .
@echo "✅ Linting complete!"
lint-check: ## Check linting without fixing
@echo "🔍 Checking linting issues..."
$(RUFF) check .
@echo "✅ Linting check complete!"
format: ## Format code with ruff
@echo "✨ Formatting code..."
$(RUFF) format .
@echo "✅ Formatting complete!"
format-check: ## Check formatting without applying
@echo "✨ Checking code formatting..."
$(RUFF) format --check .
@echo "✅ Formatting check complete!"
typecheck: ## Run type checking with pyright
@echo "🔍 Running type checking with pyright..."
$(PYRIGHT) src/
@echo "✅ Type checking complete!"
pylint: ## Run pylint analysis
@echo "🔍 Running pylint analysis..."
$(PYLINT) src/profiles --fail-under=8.0
@echo "✅ Pylint analysis complete!"
# ============================================
# Pre-commit & Push
# ============================================
.PHONY: pre-commit pre-push install-hooks
pre-commit: ## Run all pre-commit checks
@echo "🔒 Running pre-commit checks..."
$(RUFF) check .
$(RUFF) format --check .
$(PYRIGHT) src/ || @echo "⚠️ pyright check skipped (launcher issue)"
$(PYTEST) --cov --cov-fail-under=85
@echo "✅ All pre-commit checks passed!"
pre-push: ## Run comprehensive checks before push
@echo "🔒 Running comprehensive pre-push checks..."
$(RUFF) check --fix .
$(RUFF) format .
$(PYLINT) src/profiles --fail-under=8.0
$(PYRIGHT) src/
$(PYTEST) --cov --cov-fail-under=85
@echo "✅ All pre-push checks passed! Ready to push."
install-hooks: ## Install pre-commit hooks
@echo "🪝 Installing pre-commit hooks..."
uv run pre-commit install --allow-missing-config
@echo "✅ Pre-commit hooks installed!"
# ============================================
# Cleanup
# ============================================
.PHONY: clean clean-pycache clean-cov clean-all
clean: ## Remove all build artifacts
@echo "🧹 Cleaning all build artifacts..."
rm -rf .venv __pycache__ .pytest_cache .mypy_cache htmlcov coverage.xml .ruff_cache .ty_cache .coverage
@echo "✅ Cleanup complete!"
clean-pycache: ## Remove only Python cache
@echo "🧹 Removing Python cache files..."
if exist __pycache__ rmdir /s /q __pycache__
if exist .pytest_cache rmdir /s /q .pytest_cache
if exist .mypy_cache rmdir /s /q .mypy_cache
if exist .ruff_cache rmdir /s /q .ruff_cache
if exist .ty_cache rmdir /s /q .ty_cache
@echo "✅ Python cache removed!"
clean-cov: ## Remove coverage reports
@echo "🧹 Removing coverage reports..."
if exist htmlcov rmdir /s /q htmlcov
if exist coverage.xml del coverage.xml
@echo "✅ Coverage reports removed!"
clean-all: ## Clean everything including virtual environment
@echo "🧹 Cleaning everything (including .venv)..."
rm -rf .venv __pycache__ .pytest_cache .mypy_cache htmlcov coverage.xml .ruff_cache .ty_cache .coverage
@echo "✅ Everything cleaned!"
# ============================================
# Development
# ============================================
.PHONY: dev setup
dev: ## Full development setup
@echo "🚀 Setting up full development environment..."
$(MAKE) install
$(MAKE) install-hooks
@echo "✅ Development environment ready!"
setup: ## Alias for dev
$(MAKE) dev
# ============================================
# PyPI Publishing
# ============================================
.PHONY: build publish publish-test
build: ## Build distribution packages
@echo "📦 Building distribution packages..."
$(UV) build
@echo "✅ Build complete! Check dist/ folder."
publish: ## Publish to PyPI (production)
@echo "🚀 Publishing to PyPI (production)..."
$(UV) publish
@echo "✅ Published to PyPI!"
publish-test: ## Publish to TestPyPI
@echo "🚀 Publishing to TestPyPI..."
$(UV) publish --repository testpypi
@echo "✅ Published to TestPyPI!"
# ============================================
# Poetry Targets (compatibility)
# ============================================
.PHONY: poetry-install poetry-test poetry-lint poetry-format
poetry-install: ## Install with poetry (compatibility)
@echo "📦 Installing with poetry..."
poetry install
@echo "✅ Installation complete!"
poetry-test: ## Run tests with poetry (compatibility)
@echo "🧪 Running tests with poetry..."
poetry run pytest --cov
@echo "✅ Tests complete!"
poetry-lint: ## Run lint with poetry (compatibility)
@echo "🔍 Running lint with poetry..."
poetry run ruff check --fix .
@echo "✅ Linting complete!"
poetry-format: ## Format with poetry (compatibility)
@echo "✨ Formatting with poetry..."
poetry run ruff format .
@echo "✅ Formatting complete!"
# ============================================
# Help
# ============================================
.PHONY: help
help: ## Show all available commands
@echo "============================================"
@echo " ProFiles Makefile - Available Commands"
@echo "============================================"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "============================================"
.DEFAULT_GOAL := help