-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (66 loc) · 1.9 KB
/
Makefile
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
all: help
# --------------------------------------------
.PHONY: setup
setup: ## setup project with runtime dependencies
ifeq (,$(wildcard .init/setup))
@(which uv > /dev/null 2>&1) || \
(echo "banip requires uv. See README for instructions."; exit 1)
@if [ ! -d "./scratch" ]; then \
mkdir -p scratch; \
fi
@if [ ! -d "./data" ]; then \
mkdir -p data/geolite; \
fi
@if [ ! -d "./src/plugins/parsers" ]; then \
mkdir -p src/plugins/parsers; \
touch src/plugins/parsers/__init__.py; \
fi
@if [ ! -d "./src/plugins/code" ]; then \
mkdir -p src/plugins/code; \
touch src/plugins/code/__init__.py; \
fi
mkdir .init
touch .init/setup
uv sync --no-dev --frozen
else
@echo "Initial setup is already complete. If you are having issues, run:"
@echo
@echo "make reset"
@echo "make setup"
@echo
endif
# --------------------------------------------
.PHONY: dev
dev: ## add development dependencies (run make setup first)
ifneq (,$(wildcard .init/setup))
uv sync --frozen
@touch .init/dev
else
@echo "Please run \"make setup\" first"
endif
# --------------------------------------------
.PHONY: upgrade
upgrade: ## upgrade project dependencies
ifeq (,$(wildcard .init/dev))
uv sync --no-dev --upgrade
else
uv sync --upgrade
endif
# --------------------------------------------
.PHONY: reset
reset: clean ## remove venv, artifacts, and init directory
@echo Resetting project state
rm -rf .init .mypy_cache .ruff_cache .venv
# --------------------------------------------
.PHONY: clean
clean: ## cleanup python runtime artifacts
@echo Cleaning python runtime artifacts
@find . -type d -name __pycache__ -exec rm -rf {} \; -prune
rm -rf dist
# --------------------------------------------
.PHONY: help
help: ## show help
@echo Please specify a target. Choices are:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk \
'BEGIN {FS = ":.*?## "}; \
{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'