Skip to content

Commit a3023a4

Browse files
committed
fixed timeout bug
1 parent d26b4e6 commit a3023a4

16 files changed

+1800
-343
lines changed

Makefile

Lines changed: 184 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,195 @@
1-
.PHONY: clean test run build publish
1+
.PHONY: clean clean-pyc clean-build clean-test clean-all test run build publish help install dev-install
22

3-
# Remove Python bytecode, __pycache__ directories, and build artifacts.
4-
clean:
5-
@echo "Cleaning project..."
6-
@find . -type f -name '*.pyc' -delete
7-
@find . -type d -name '__pycache__' -delete
8-
@rm -rf build/ dist/ *.egg-info
9-
@echo "Clean complete."
3+
# Default target
4+
help:
5+
@echo "Available targets:"
6+
@echo " clean - Remove Python bytecode and basic artifacts"
7+
@echo " clean-all - Deep clean everything (pyc, build, test, cache)"
8+
@echo " clean-pyc - Remove Python bytecode files"
9+
@echo " clean-build - Remove build artifacts"
10+
@echo " clean-test - Remove test artifacts"
11+
@echo " install - Install package in current environment"
12+
@echo " dev-install - Install package in development mode"
13+
@echo " test - Run tests"
14+
@echo " run - Run the server"
15+
@echo " build - Build the project"
16+
@echo " publish - Build and publish to PyPI"
1017

11-
# Run the server launcher.
18+
# Basic clean - Python bytecode and common artifacts
19+
clean: clean-pyc clean-build
20+
@echo "Basic clean complete."
21+
22+
# Remove Python bytecode files and __pycache__ directories
23+
clean-pyc:
24+
@echo "Cleaning Python bytecode files..."
25+
@find . -type f -name '*.pyc' -delete 2>/dev/null || true
26+
@find . -type f -name '*.pyo' -delete 2>/dev/null || true
27+
@find . -type d -name '__pycache__' -exec rm -rf {} + 2>/dev/null || true
28+
@find . -type d -name '*.egg-info' -exec rm -rf {} + 2>/dev/null || true
29+
30+
# Remove build artifacts
31+
clean-build:
32+
@echo "Cleaning build artifacts..."
33+
@rm -rf build/ dist/ *.egg-info 2>/dev/null || true
34+
@rm -rf .eggs/ 2>/dev/null || true
35+
@find . -name '*.egg' -exec rm -f {} + 2>/dev/null || true
36+
37+
# Remove test artifacts
38+
clean-test:
39+
@echo "Cleaning test artifacts..."
40+
@rm -rf .pytest_cache/ 2>/dev/null || true
41+
@rm -rf .coverage 2>/dev/null || true
42+
@rm -rf htmlcov/ 2>/dev/null || true
43+
@rm -rf .tox/ 2>/dev/null || true
44+
@rm -rf .cache/ 2>/dev/null || true
45+
@find . -name '.coverage.*' -delete 2>/dev/null || true
46+
47+
# Deep clean - everything
48+
clean-all: clean-pyc clean-build clean-test
49+
@echo "Deep cleaning..."
50+
@rm -rf .mypy_cache/ 2>/dev/null || true
51+
@rm -rf .ruff_cache/ 2>/dev/null || true
52+
@rm -rf .uv/ 2>/dev/null || true
53+
@rm -rf node_modules/ 2>/dev/null || true
54+
@find . -name '.DS_Store' -delete 2>/dev/null || true
55+
@find . -name 'Thumbs.db' -delete 2>/dev/null || true
56+
@find . -name '*.log' -delete 2>/dev/null || true
57+
@find . -name '*.tmp' -delete 2>/dev/null || true
58+
@find . -name '*~' -delete 2>/dev/null || true
59+
@echo "Deep clean complete."
60+
61+
# Install package
62+
install:
63+
@echo "Installing package..."
64+
pip install .
65+
66+
# Install package in development mode
67+
dev-install:
68+
@echo "Installing package in development mode..."
69+
pip install -e .
70+
71+
# Run tests
72+
test:
73+
@echo "Running tests..."
74+
@if command -v uv >/dev/null 2>&1; then \
75+
uv run pytest; \
76+
elif command -v pytest >/dev/null 2>&1; then \
77+
pytest; \
78+
else \
79+
python -m pytest; \
80+
fi
81+
82+
# Run tests with coverage
83+
test-cov:
84+
@echo "Running tests with coverage..."
85+
@if command -v uv >/dev/null 2>&1; then \
86+
uv run pytest --cov=src --cov-report=html --cov-report=term; \
87+
else \
88+
pytest --cov=src --cov-report=html --cov-report=term; \
89+
fi
90+
91+
# Run the server launcher
1292
run:
1393
@echo "Running server..."
14-
PYTHONPATH=src python3 -m chuk_protocol_server.server_launcher
94+
@if command -v uv >/dev/null 2>&1; then \
95+
PYTHONPATH=src uv run python -m chuk_protocol_server.server_launcher; \
96+
else \
97+
PYTHONPATH=src python3 -m chuk_protocol_server.server_launcher; \
98+
fi
1599

16-
# Build the project using the pyproject.toml configuration.
17-
build:
100+
# Build the project using the pyproject.toml configuration
101+
build: clean-build
18102
@echo "Building project..."
19-
python3 -m build
103+
@if command -v uv >/dev/null 2>&1; then \
104+
uv build; \
105+
else \
106+
python3 -m build; \
107+
fi
20108
@echo "Build complete. Distributions are in the 'dist' folder."
21109

22-
# Publish the package to PyPI using twine.
23-
# This target uploads only the most recent artifact in the 'dist' folder.
110+
# Publish the package to PyPI using twine
24111
publish: build
25112
@echo "Publishing package..."
26-
@last_build=$$(ls -t dist/* | head -n 1); \
27-
echo "Uploading $$last_build"; \
113+
@if [ ! -d "dist" ] || [ -z "$$(ls -A dist 2>/dev/null)" ]; then \
114+
echo "Error: No distribution files found. Run 'make build' first."; \
115+
exit 1; \
116+
fi
117+
@last_build=$$(ls -t dist/*.tar.gz dist/*.whl 2>/dev/null | head -n 2); \
118+
if [ -z "$$last_build" ]; then \
119+
echo "Error: No valid distribution files found."; \
120+
exit 1; \
121+
fi; \
122+
echo "Uploading: $$last_build"; \
28123
twine upload $$last_build
29-
@echo "Publish complete."
124+
@echo "Publish complete."
125+
126+
# Publish to test PyPI
127+
publish-test: build
128+
@echo "Publishing to test PyPI..."
129+
@last_build=$$(ls -t dist/*.tar.gz dist/*.whl 2>/dev/null | head -n 2); \
130+
if [ -z "$$last_build" ]; then \
131+
echo "Error: No valid distribution files found."; \
132+
exit 1; \
133+
fi; \
134+
echo "Uploading to test PyPI: $$last_build"; \
135+
twine upload --repository testpypi $$last_build
136+
137+
# Check code quality
138+
lint:
139+
@echo "Running linters..."
140+
@if command -v uv >/dev/null 2>&1; then \
141+
uv run ruff check .; \
142+
uv run ruff format --check .; \
143+
elif command -v ruff >/dev/null 2>&1; then \
144+
ruff check .; \
145+
ruff format --check .; \
146+
else \
147+
echo "Ruff not found. Install with: pip install ruff"; \
148+
fi
149+
150+
# Fix code formatting
151+
format:
152+
@echo "Formatting code..."
153+
@if command -v uv >/dev/null 2>&1; then \
154+
uv run ruff format .; \
155+
uv run ruff check --fix .; \
156+
elif command -v ruff >/dev/null 2>&1; then \
157+
ruff format .; \
158+
ruff check --fix .; \
159+
else \
160+
echo "Ruff not found. Install with: pip install ruff"; \
161+
fi
162+
163+
# Type checking
164+
typecheck:
165+
@echo "Running type checker..."
166+
@if command -v uv >/dev/null 2>&1; then \
167+
uv run mypy src; \
168+
elif command -v mypy >/dev/null 2>&1; then \
169+
mypy src; \
170+
else \
171+
echo "MyPy not found. Install with: pip install mypy"; \
172+
fi
173+
174+
# Run all checks
175+
check: lint typecheck test
176+
@echo "All checks completed."
177+
178+
# Show project info
179+
info:
180+
@echo "Project Information:"
181+
@echo "==================="
182+
@if [ -f "pyproject.toml" ]; then \
183+
echo "pyproject.toml found"; \
184+
if command -v uv >/dev/null 2>&1; then \
185+
echo "UV version: $$(uv --version)"; \
186+
fi; \
187+
if command -v python >/dev/null 2>&1; then \
188+
echo "Python version: $$(python --version)"; \
189+
fi; \
190+
else \
191+
echo "No pyproject.toml found"; \
192+
fi
193+
@echo "Current directory: $$(pwd)"
194+
@echo "Git status:"
195+
@git status --porcelain 2>/dev/null || echo "Not a git repository"

0 commit comments

Comments
 (0)