[Makefile] lazily setup lintrunner on first make lint run (#156058)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/156058
Approved by: https://github.com/ezyang
This commit is contained in:
Xuehai Pan
2025-06-19 12:39:44 +08:00
committed by PyTorch MergeBot
parent 242eb19c83
commit 1c960c5638
2 changed files with 22 additions and 12 deletions

View File

@ -57,19 +57,35 @@ setup-env-cuda:
setup-env-rocm:
$(MAKE) setup-env PYTHON="$(PYTHON)" NIGHTLY_TOOL_OPTS="$(NIGHTLY_TOOL_OPTS) --rocm"
.PHONY: setup-lint
setup-lint:
.lintbin/.lintrunner.sha256: requirements.txt pyproject.toml .lintrunner.toml
@echo "Setting up lintrunner..."
$(PIP) install lintrunner
lintrunner init
@echo "Generating .lintrunner.sha256..."
@mkdir -p .lintbin
@sha256sum requirements.txt pyproject.toml .lintrunner.toml > .lintbin/.lintrunner.sha256
.PHONY: setup-lint
setup-lint: .lintbin/.lintrunner.sha256
.PHONY: lazy-setup-lint
lazy-setup-lint: .lintbin/.lintrunner.sha256
@if [ ! -x "$(shell command -v lintrunner)" ]; then \
$(MAKE) setup-lint; \
fi
.PHONY: lint
lint:
lintrunner
lint: lazy-setup-lint
lintrunner --all-files
.PHONY: quicklint
quicklint:
quicklint: lazy-setup-lint
lintrunner
.PHONY: quickfix
quickfix: lazy-setup-lint
lintrunner --apply-patches
# Deprecated target aliases
.PHONY: setup_env setup_env_cuda setup_env_rocm setup_lint
setup_env: setup-env