forked from corbett3000/OpenDNA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (77 loc) · 2.34 KB
/
Copy pathMakefile
File metadata and controls
104 lines (77 loc) · 2.34 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
.PHONY: install dev test lint format typecheck serve start stop kill restart status logs \
scan update-db build-annotations build-macos lock outdated clean
PORT ?= 8787
PID_FILE ?= /tmp/opendna.pid
LOG_FILE ?= /tmp/opendna-server.log
# --- Setup ---
install:
uv sync --all-extras --dev
dev: install
lock:
uv lock --upgrade
outdated:
uv pip list --outdated
# --- Quality ---
test:
uv run pytest -v -W ignore::DeprecationWarning
lint:
uv run ruff check src tests
format:
uv run ruff format src tests
typecheck:
uv run mypy src
# --- Run (foreground) ---
serve:
uv run opendna serve --port $(PORT)
scan:
uv run opendna scan $(FILE)
update-db:
uv run opendna update-db
# --- Server lifecycle (background) ---
start:
@lsof -ti:$(PORT) 2>/dev/null && echo "Server already running on port $(PORT)" || \
( nohup uv run opendna serve --port $(PORT) > $(LOG_FILE) 2>&1 & \
echo $$! > $(PID_FILE) && \
echo "Started OpenDNA on http://127.0.0.1:$(PORT) (pid $$(cat $(PID_FILE)))" )
stop:
@if [ -f $(PID_FILE) ]; then \
kill $$(cat $(PID_FILE)) 2>/dev/null && \
rm -f $(PID_FILE) && \
echo "Stopped OpenDNA" || \
echo "Process already exited"; \
elif lsof -ti:$(PORT) 2>/dev/null; then \
kill $$(lsof -ti:$(PORT)) 2>/dev/null && \
echo "Stopped OpenDNA (pid from port)"; \
else \
echo "OpenDNA is not running"; \
fi
kill:
@lsof -ti:$(PORT) 2>/dev/null | xargs kill -9 2>/dev/null && \
echo "Killed OpenDNA on port $(PORT)" || \
echo "Nothing running on port $(PORT)"
@rm -f $(PID_FILE) 2>/dev/null || true
restart: stop start
status:
@if [ -f $(PID_FILE) ] && kill -0 $$(cat $(PID_FILE)) 2>/dev/null; then \
echo "OpenDNA is running (pid $$(cat $(PID_FILE))) on http://127.0.0.1:$(PORT)"; \
elif lsof -ti:$(PORT) 2>/dev/null; then \
echo "OpenDNA is running on http://127.0.0.1:$(PORT) (no pid file)"; \
else \
echo "OpenDNA is not running"; \
fi
logs:
@if [ -f $(LOG_FILE) ]; then \
tail -f $(LOG_FILE); \
else \
echo "No log file found at $(LOG_FILE)"; \
fi
# --- Scripts ---
build-annotations:
uv run python scripts/build_annotations.py --source all
build-macos:
@bash scripts/build_macos_shell.sh
# --- Clean ---
clean:
rm -rf .venv build dist *.egg-info uv.lock $(PID_FILE)
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name '*.pyc' -delete