[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

@ -343,13 +343,7 @@ command runs tests such as `TestNN.test_BCELoss` and
### Local linting ### Local linting
Install all prerequisites by running You can run the same linting steps that are used in CI locally via `make`:
```bash
make setup-lint
```
You can now run the same linting steps that are used in CI locally via `make`:
```bash ```bash
make lint make lint

View File

@ -57,19 +57,35 @@ setup-env-cuda:
setup-env-rocm: setup-env-rocm:
$(MAKE) setup-env PYTHON="$(PYTHON)" NIGHTLY_TOOL_OPTS="$(NIGHTLY_TOOL_OPTS) --rocm" $(MAKE) setup-env PYTHON="$(PYTHON)" NIGHTLY_TOOL_OPTS="$(NIGHTLY_TOOL_OPTS) --rocm"
.PHONY: setup-lint .lintbin/.lintrunner.sha256: requirements.txt pyproject.toml .lintrunner.toml
setup-lint: @echo "Setting up lintrunner..."
$(PIP) install lintrunner $(PIP) install lintrunner
lintrunner init 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 .PHONY: lint
lint: lint: lazy-setup-lint
lintrunner lintrunner --all-files
.PHONY: quicklint .PHONY: quicklint
quicklint: quicklint: lazy-setup-lint
lintrunner lintrunner
.PHONY: quickfix
quickfix: lazy-setup-lint
lintrunner --apply-patches
# Deprecated target aliases # Deprecated target aliases
.PHONY: setup_env setup_env_cuda setup_env_rocm setup_lint .PHONY: setup_env setup_env_cuda setup_env_rocm setup_lint
setup_env: setup-env setup_env: setup-env