forked from bentoml/BentoML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (56 loc) · 2.73 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
SHELL := /bin/bash
.DEFAULT_GOAL := help
GIT_ROOT ?= $(shell git rev-parse --show-toplevel)
USE_VERBOSE ?=false
USE_GPU ?= false
USE_GRPC ?= false
help: ## Show all Makefile targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: format format-proto lint lint-proto type style clean
format: ## Running code formatter: black and isort
@echo "(black) Formatting codebase..."
@black --config pyproject.toml src tests docs examples
@echo "(black) Formatting stubs..."
@find src -name "*.pyi" ! -name "*_pb2*" -exec black --pyi --config pyproject.toml {} \;
@echo "(isort) Reordering imports..."
isort .
format-proto: ## Running proto formatter: buf
@echo "Formatting proto files..."
docker run --init --rm --volume $(GIT_ROOT)/src:/workspace --workdir /workspace bufbuild/buf format --config "/workspace/bentoml/grpc/buf.yaml" -w bentoml/grpc
lint: ## Running lint checker: pylint
@echo "(pylint) Linting bentoml..."
@pylint --rcfile=pyproject.toml --fail-under 9.5 src
@echo "(pylint) Linting examples..."
@pylint --rcfile=pyproject.toml --fail-under 9.5 examples
@echo "(pylint) Linting tests..."
@pylint --rcfile=pyproject.toml --fail-under 9.5 tests
lint-proto: ## Running proto lint checker: buf
@echo "Linting proto files..."
docker run --init --rm --volume $(GIT_ROOT)/src:/workspace --workdir /workspace bufbuild/buf lint --config "/workspace/bentoml/grpc/buf.yaml" --error-format msvs bentoml/grpc
type: ## Running type checker: pyright
@echo "(pyright) Typechecking codebase..."
@pyright -p src -w
style: format lint format-proto lint-proto ## Running formatter and linter
clean: ## Clean all generated files
@echo "Cleaning all generated files..."
@cd $(GIT_ROOT)/docs && make clean
@cd $(GIT_ROOT) || exit 1
@find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
# Docs
watch-docs: install-docs-deps ## Build and watch documentation
sphinx-autobuild docs/source docs/build/html --watch $(GIT_ROOT)/bentoml --ignore "bazel-*"
spellcheck-docs: ## Spell check documentation
sphinx-build -b spelling ./docs/source ./docs/build || (echo "Error running spellchecker.. You may need to run 'make install-spellchecker-deps'"; exit 1)
OS := $(shell uname)
ifeq ($(OS),Darwin)
install-spellchecker-deps: ## Install MacOS dependencies for spellchecker
brew install enchant
pip install sphinxcontrib-spelling
else ifneq ("$(wildcard $(/etc/debian_version))","")
install-spellchecker-deps: ## Install Debian-based dependencies for spellchecker
sudo apt install libenchant-dev
else
install-spellchecker-deps: ## Inform users to install enchant depending on their distros
@echo Make sure to install enchant from your distros package manager
@exit 1
endif