Makefile 1.87 KB
Newer Older
1
.PHONY: check-deps install-deps format update help
2

3
4
5
6
7
8
# Show help for each target
help:
	@echo "Available targets:"
	@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

check-deps: ## Check and install required Python formatting dependencies
9
10
11
	@command -v isort >/dev/null 2>&1 || (echo "Installing isort..." && pip install isort)
	@command -v black >/dev/null 2>&1 || (echo "Installing black..." && pip install black)

12
install-deps: ## Install Python formatting tools (isort and black)
13
14
	pip install isort black

15
format: check-deps ## Format modified Python files using isort and black
16
17
	@echo "Formatting modified Python files..."
	git diff --name-only --diff-filter=M | grep '\.py$$' | xargs -I {} sh -c 'isort {} && black {}'
18
19
20

FILES_TO_UPDATE = docker/Dockerfile.rocm \
                 python/pyproject.toml \
Yineng Zhang's avatar
Yineng Zhang committed
21
                 python/pyproject_other.toml \
22
                 python/sglang/version.py \
Yineng Zhang's avatar
Yineng Zhang committed
23
24
25
26
                 docs/developer_guide/setup_github_runner.md \
                 docs/get_started/install.md \
                 docs/platforms/amd_gpu.md \
                 docs/platforms/ascend_npu.md \
Baizhou Zhang's avatar
Baizhou Zhang committed
27
				 benchmark/deepseek_v3/README.md
28

29
update: ## Update version numbers across project files. Usage: make update <new_version>
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
	@if [ -z "$(filter-out $@,$(MAKECMDGOALS))" ]; then \
		echo "Version required. Usage: make update <new_version>"; \
		exit 1; \
	fi
	@OLD_VERSION=$$(grep "version" python/sglang/version.py | cut -d '"' -f2); \
	NEW_VERSION=$(filter-out $@,$(MAKECMDGOALS)); \
	echo "Updating version from $$OLD_VERSION to $$NEW_VERSION"; \
	for file in $(FILES_TO_UPDATE); do \
		if [ "$(shell uname)" = "Darwin" ]; then \
			sed -i '' -e "s/$$OLD_VERSION/$$NEW_VERSION/g" $$file; \
		else \
			sed -i -e "s/$$OLD_VERSION/$$NEW_VERSION/g" $$file; \
		fi \
	done; \
	echo "Version update complete"

%:
	@: