forked from langroid/langroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
132 lines (102 loc) · 2.89 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
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
.PHONY: setup check lint tests docs nodocs loc
SHELL := /bin/bash
.PHONY: setup update
setup: ## Setup the git pre-commit hooks
uv run pre-commit install
update: ## Update the git pre-commit hooks
uv run pre-commit autoupdate
.PHONY: type-check
type-check:
@uv run pre-commit install
@uv run pre-commit autoupdate
@uv run pre-commit run --all-files
@echo "Running black..."
@black --check .
@echo "Running flake8 on git-tracked files ONLY! ..."
@git ls-files | grep '\.py$$' | xargs flake8 --exclude=.git,__pycache__,.venv,langroid/embedding_models/protoc/*
@uv run ruff check .
@echo "Running mypy...";
@uv run mypy -p langroid
@echo "All checks passed!"
.PHONE: lint
lint:
uv run black .
uv run ruff check . --fix
.PHONY: stubs
stubs:
@echo "Generating Python stubs for the langroid package..."
@uv run stubgen -p langroid -o stubs
@echo "Stubs generated in the 'stubs' directory"
.PHONY: fix-pydantic
# Entry to replace pydantic imports in specified directories
fix-pydantic:
@echo "Fixing pydantic imports..."
@chmod +x scripts/fix-pydantic-imports.sh
@./scripts/fix-pydantic-imports.sh
.PHONY: check
check: fix-pydantic lint type-check
.PHONY: tests
tests:
pytest tests/main --basetemp=/tmp/pytest
docs:
@# Kill any existing 'mkdocs serve' processes.
@pkill -f "mkdocs serve" 2>/dev/null || true
@# Build the documentation.
mkdocs build
@# Serve the documentation in the background.
mkdocs serve &
@echo "Documentation is being served in the background."
@echo "You can access the documentation at http://127.0.0.1:8000/"
nodocs:
@# Kill any existing 'mkdocs serve' processes.
@pkill -f "mkdocs serve" 2>/dev/null || echo "No 'mkdocs serve' process found."
@echo "Stopped serving documentation."
loc:
@echo "Lines in git-tracked files python files:"
@git ls-files | grep '\.py$$' | xargs cat | grep -v '^\s*$$' | wc -l
.PHONY: revert-tag
revert-tag:
@LATEST_TAG=$$(git describe --tags --abbrev=0) && \
echo "Deleting tag: $$LATEST_TAG" && \
git tag -d $$LATEST_TAG
.PHONY: revert-bump
revert-bump:
@if git log -1 --pretty=%B | grep -q "bump"; then \
git reset --hard HEAD~1; \
echo "Reverted last commit (bump commit)"; \
else \
echo "Last commit was not a bump commit"; \
fi
.PHONY: revert
revert: revert-bump revert-tag
.PHONY: bump-patch
bump-patch:
@cz bump --increment PATCH
.PHONY: bump-minor
bump-minor:
@cz bump --increment MINOR
.PHONY: bump-major
bump-major:
@cz bump --increment MAJOR
.PHONY: build
build:
@uv build
.PHONY: push
push:
@git push origin main
@git push origin --tags
.PHONY: clean
clean:
-rm -rf dist/*
.PHONY: release
release:
@VERSION=$$(cz version -p | cut -d' ' -f2) && gh release create $${VERSION} dist/*
.PHONY: all-patch
all-patch: bump-patch clean build push release
.PHONY: all-minor
all-minor: bump-minor clean build push release
.PHONY: all-major
all-major: bump-major clean build push release
.PHONY: publish
publish:
uv publish