-
Notifications
You must be signed in to change notification settings - Fork 371
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (58 loc) · 2.09 KB
/
Makefile
File metadata and controls
64 lines (58 loc) · 2.09 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
.PHONY: lint lint-flake8 lint-print install-flake8
install-flake8:
@for pkg in flake8-quotes flake8-bugbear; do \
case $$pkg in \
flake8-quotes) mod="flake8_quotes" ;; \
flake8-bugbear) mod="bugbear" ;; \
esac; \
python3 -c "import importlib.util, sys; sys.exit(0 if importlib.util.find_spec('$$mod') else 1)" \
|| pip install $$pkg; \
done
lint-flake8:
python -m flake8
.ONESHELL:
lint-flake8-only-diff:
@set -e
@if [ -n "${CHANGED_FILES}" ]; then \
echo "$(CHANGED_FILES)" | xargs flake8; \
exit 0; \
fi
@echo "🔍 Collecting changed Python files..."
@FILES=$$( \
{ \
git diff --name-status origin/main..HEAD -- 'lazyllm/**.py' 'docs/**.py' 'scripts/**.py' 'tests/**.py' 'examples/**.py'; \
git diff --cached --name-status -- 'lazyllm/**.py' 'docs/**.py' 'scripts/**.py' 'tests/**.py' 'examples/**.py'; \
git diff --name-status -- 'lazyllm/**.py' 'docs/**.py' 'scripts/**.py' 'tests/**.py' 'examples/**.py'; \
} | awk '$$1 ~ /^(A|M)$$/ {print $$2}' | sort -u \
); \
if [ -n "$$FILES" ]; then \
echo "➡️ Running flake8 on:"; \
echo "$$FILES"; \
echo "$$FILES" | xargs flake8; \
else \
echo "✅ No Python file changes to lint."; \
fi
lint-print:
@matches=$$(grep -RIn --binary-files=without-match --include="*.py" --exclude-dir="__pycache__" --exclude="finetune.py" --exclude-dir="docs" 'print(' lazyllm \
| grep -v '^\s*#' \
| grep -v '# noqa print' || true); \
if [ -n "$$matches" ]; then \
count=$$(echo "$$matches" | wc -l); \
echo "❌ Lint failed: found $$count print(...) statements in the codebase:"; \
echo "$$matches"; \
exit 1; \
else \
echo "✅ Lint passed: no print(...) statements found."; \
fi
lint: install-flake8 lint-flake8 lint-print
lint-only-diff: install-flake8 lint-flake8-only-diff lint-print
poetry-install:
cp pyproject.toml pyproject.toml.backup; \
python scripts/generate_toml_optional_deps.py; \
poetry install; \
mv pyproject.toml.backup pyproject.toml
poetry-lock:
cp pyproject.toml pyproject.toml.backup; \
python scripts/generate_toml_optional_deps.py; \
poetry lock; \
mv pyproject.toml.backup pyproject.toml