-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
110 lines (99 loc) · 3.86 KB
/
Copy pathMakefile
File metadata and controls
110 lines (99 loc) · 3.86 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
# Makefile
.PHONY: help install build build-ui server clean tests export-requirements
PROJECT_ROOT := $(CURDIR)
## help: Show this help message
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " install # Install the project in editable mode with all dev dependencies"
@echo " build # Run the build script"
@echo " build-ui # Build Vue UI and copy dist to api/static"
@echo " server # Start the Uvicorn server"
@echo " clean # Clean build artifacts"
@echo " tests # Run the tests using pytest"
@echo " export-requirements # Export requirements.txt (production) and requirements-dev.txt (development)"
## install: Install the project in editable mode
install:
@echo "Setting up development environment..."
@if [ ! -d ".venv" ]; then \
echo "Creating virtual environment..."; \
if command -v uv >/dev/null 2>&1; then \
uv venv; \
elif command -v python3 >/dev/null 2>&1; then \
python3 -m venv .venv; \
elif command -v python >/dev/null 2>&1; then \
python -m venv .venv; \
else \
echo "Python not found. Please install Python."; exit 1; \
fi \
fi
@if command -v uv >/dev/null 2>&1; then \
echo "Syncing dependencies with uv..."; \
uv sync --all-extras; \
else \
echo "uv not found, falling back to pip..."; \
if [ -f "pyproject.toml" ]; then \
.venv/bin/python -m pip install -e ".[dev]" 2>/dev/null || .venv/Scripts/python.exe -m pip install -e ".[dev]"; \
else \
echo "No pyproject.toml found."; \
fi \
fi
@.venv/bin/python scripts/download_model.py 2>/dev/null || .venv/Scripts/python.exe scripts/download_model.py
@echo "Installing pre-commit hooks..."
@.venv/bin/pre-commit install 2>/dev/null || .venv/Scripts/pre-commit.exe install 2>/dev/null || echo "pre-commit install skipped (not found)"
@echo "Development environment ready!"
## build-ui: Build Vue UI and copy dist to api/static
build-ui:
@echo "Building Vue UI..."
@cd WordFormatUI && npm ci && npm run build
@echo "Copying dist to src/wordformat/api/static/..."
@rm -rf src/wordformat/api/static/*
@cp -r WordFormatUI/dist/* src/wordformat/api/static/
@echo "UI build complete."
## build: Run the build script (scripts/build.bat)
build: install
@echo "Running build script..."
@if [ "$$(uname -s)" = "Linux" ] || [ "$$(uname -s)" = "Darwin" ]; then \
echo "Detected Unix-like system, using build.sh..."; \
chmod +x scripts/build.sh; \
scripts/build.sh "$(PROJECT_ROOT)"; \
elif [ "$$OS" = "Windows_NT" ] || [ -n "$$WINDIR" ]; then \
echo "Detected Windows, using build.bat..."; \
scripts/build.bat "$(PROJECT_ROOT)"; \
else \
echo "Unsupported platform!"; exit 1; \
fi
## server: Start the Uvicorn development server
server:
uvicorn wordformat.api:app --host 0.0.0.0 --port 8000
## lint: Run code quality checks
lint:
@echo "Running ruff check..."
@ruff check --fix src/
@echo "Running ruff format..."
@ruff format src/
@echo "All checks passed!"
## tests: Run lint then tests
tests: lint
@echo "Running tests..."
@pytest tests/ --cov=wordformat --cov-report=term-missing --cov-fail-under=87
## export-requirements: Export requirements files from pyproject.toml
export-requirements:
@echo "Exporting requirements files..."
@uv export --no-hashes -o requirements.txt
@uv export --no-hashes --all-extras -o requirements-dev.txt
@echo "Generated:"
@echo " requirements.txt (production, core dependencies only)"
@echo " requirements-dev.txt (development, includes test/api/build tools)"
## clean: Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
@if [ "$$(uname -s)" = "Linux" ] || [ "$$(uname -s)" = "Darwin" ]; then \
rm -rf dist/ build/ output/ *.spec 2>/dev/null; \
echo "Clean complete (Unix)."; \
elif [ "$$OS" = "Windows_NT" ] || [ -n "$$WINDIR" ]; then \
scripts/clean.bat; \
else \
echo "Unknown OS, skipping clean."; \
fi