forked from IBM/mcp-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
229 lines (209 loc) · 7.11 KB
/
Makefile
File metadata and controls
229 lines (209 loc) · 7.11 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
.PHONY: clean clean-pyc clean-build clean-test clean-all test run build publish help install dev-install
# Default target
help:
@echo "Available targets:"
@echo " clean - Remove Python bytecode and basic artifacts"
@echo " clean-all - Deep clean everything (pyc, build, test, cache)"
@echo " clean-pyc - Remove Python bytecode files"
@echo " clean-build - Remove build artifacts"
@echo " clean-test - Remove test artifacts"
@echo " install - Install package in current environment"
@echo " dev-install - Install package in development mode"
@echo " test - Run tests"
@echo " test-cov - Run tests with coverage report"
@echo " coverage-report - Show current coverage report"
@echo " lint - Run code linters"
@echo " format - Auto-format code"
@echo " typecheck - Run type checking"
@echo " check - Run all checks (lint, typecheck, test)"
@echo " run - Run the server"
@echo " build - Build the project"
@echo " publish - Build and publish to PyPI"
# Basic clean - Python bytecode and common artifacts
clean: clean-pyc clean-build
@echo "Basic clean complete."
# Remove Python bytecode files and __pycache__ directories
clean-pyc:
@echo "Cleaning Python bytecode files..."
@find . -type f -name '*.pyc' -delete 2>/dev/null || true
@find . -type f -name '*.pyo' -delete 2>/dev/null || true
@find . -type d -name '__pycache__' -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name '*.egg-info' -exec rm -rf {} + 2>/dev/null || true
# Remove build artifacts
clean-build:
@echo "Cleaning build artifacts..."
@rm -rf build/ dist/ *.egg-info 2>/dev/null || true
@rm -rf .eggs/ 2>/dev/null || true
@find . -name '*.egg' -exec rm -f {} + 2>/dev/null || true
# Remove test artifacts
clean-test:
@echo "Cleaning test artifacts..."
@rm -rf .pytest_cache/ 2>/dev/null || true
@rm -rf .coverage 2>/dev/null || true
@rm -rf htmlcov/ 2>/dev/null || true
@rm -rf .tox/ 2>/dev/null || true
@rm -rf .cache/ 2>/dev/null || true
@find . -name '.coverage.*' -delete 2>/dev/null || true
# Deep clean - everything
clean-all: clean-pyc clean-build clean-test
@echo "Deep cleaning..."
@rm -rf .mypy_cache/ 2>/dev/null || true
@rm -rf .ruff_cache/ 2>/dev/null || true
@rm -rf .uv/ 2>/dev/null || true
@rm -rf node_modules/ 2>/dev/null || true
@find . -name '.DS_Store' -delete 2>/dev/null || true
@find . -name 'Thumbs.db' -delete 2>/dev/null || true
@find . -name '*.log' -delete 2>/dev/null || true
@find . -name '*.tmp' -delete 2>/dev/null || true
@find . -name '*~' -delete 2>/dev/null || true
@echo "Deep clean complete."
# Install package
install:
@echo "Installing package..."
pip install .
# Install package in development mode
dev-install:
@echo "Installing package in development mode..."
pip install -e .
# Run tests
test:
@echo "Running tests..."
@if command -v uv >/dev/null 2>&1; then \
uv run pytest; \
elif command -v pytest >/dev/null 2>&1; then \
pytest; \
else \
python -m pytest; \
fi
# Show current coverage report
coverage-report:
@echo "Coverage Report:"
@echo "================"
@if command -v uv >/dev/null 2>&1; then \
uv run coverage report --omit="tests/*" || echo "No coverage data found. Run 'make test-cov' first."; \
else \
coverage report --omit="tests/*" || echo "No coverage data found. Run 'make test-cov' first."; \
fi
# Run tests with coverage
test-cov:
@echo "Running tests with coverage..."
@if command -v uv >/dev/null 2>&1; then \
uv run pytest --cov=src --cov-report=html --cov-report=term --cov-report=term-missing:skip-covered; \
exit_code=$$?; \
echo ""; \
echo "=========================="; \
echo "Coverage Summary:"; \
echo "=========================="; \
uv run coverage report --omit="tests/*" | tail -5; \
echo ""; \
echo "HTML coverage report saved to: htmlcov/index.html"; \
exit $$exit_code; \
else \
pytest --cov=src --cov-report=html --cov-report=term --cov-report=term-missing:skip-covered; \
exit_code=$$?; \
echo ""; \
echo "=========================="; \
echo "Coverage Summary:"; \
echo "=========================="; \
coverage report --omit="tests/*" | tail -5; \
echo ""; \
echo "HTML coverage report saved to: htmlcov/index.html"; \
exit $$exit_code; \
fi
# Run the server launcher
run:
@echo "Running server..."
@if command -v uv >/dev/null 2>&1; then \
PYTHONPATH=src uv run python -m chuk_protocol_server.server_launcher; \
else \
PYTHONPATH=src python3 -m chuk_protocol_server.server_launcher; \
fi
# Build the project using the pyproject.toml configuration
build: clean-build
@echo "Building project..."
@if command -v uv >/dev/null 2>&1; then \
uv build; \
else \
python3 -m build; \
fi
@echo "Build complete. Distributions are in the 'dist' folder."
# Publish the package to PyPI using twine
publish: build
@echo "Publishing package..."
@if [ ! -d "dist" ] || [ -z "$$(ls -A dist 2>/dev/null)" ]; then \
echo "Error: No distribution files found. Run 'make build' first."; \
exit 1; \
fi
@last_build=$$(ls -t dist/*.tar.gz dist/*.whl 2>/dev/null | head -n 2); \
if [ -z "$$last_build" ]; then \
echo "Error: No valid distribution files found."; \
exit 1; \
fi; \
echo "Uploading: $$last_build"; \
twine upload $$last_build
@echo "Publish complete."
# Publish to test PyPI
publish-test: build
@echo "Publishing to test PyPI..."
@last_build=$$(ls -t dist/*.tar.gz dist/*.whl 2>/dev/null | head -n 2); \
if [ -z "$$last_build" ]; then \
echo "Error: No valid distribution files found."; \
exit 1; \
fi; \
echo "Uploading to test PyPI: $$last_build"; \
twine upload --repository testpypi $$last_build
# Check code quality
lint:
@echo "Running linters..."
@if command -v uv >/dev/null 2>&1; then \
uv run ruff check .; \
uv run ruff format --check .; \
elif command -v ruff >/dev/null 2>&1; then \
ruff check .; \
ruff format --check .; \
else \
echo "Ruff not found. Install with: pip install ruff"; \
fi
# Fix code formatting
format:
@echo "Formatting code..."
@if command -v uv >/dev/null 2>&1; then \
uv run ruff format .; \
uv run ruff check --fix .; \
elif command -v ruff >/dev/null 2>&1; then \
ruff format .; \
ruff check --fix .; \
else \
echo "Ruff not found. Install with: pip install ruff"; \
fi
# Type checking
typecheck:
@echo "Running type checker..."
@if command -v uv >/dev/null 2>&1; then \
uv run mypy src --no-site-packages; \
elif command -v mypy >/dev/null 2>&1; then \
mypy src --no-site-packages; \
else \
echo "MyPy not found. Install with: pip install mypy"; \
fi
# Run all checks
check: lint typecheck test
@echo "All checks completed."
# Show project info
info:
@echo "Project Information:"
@echo "==================="
@if [ -f "pyproject.toml" ]; then \
echo "pyproject.toml found"; \
if command -v uv >/dev/null 2>&1; then \
echo "UV version: $$(uv --version)"; \
fi; \
if command -v python >/dev/null 2>&1; then \
echo "Python version: $$(python --version)"; \
fi; \
else \
echo "No pyproject.toml found"; \
fi
@echo "Current directory: $$(pwd)"
@echo "Git status:"
@git status --porcelain 2>/dev/null || echo "Not a git repository"