-
-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (87 loc) · 4.09 KB
/
Copy pathMakefile
File metadata and controls
126 lines (87 loc) · 4.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
PY_DIR = .
PACKAGE_DIR = ${PY_DIR}/torchcam
PYPROJECT_FILE = ${PY_DIR}/pyproject.toml
PYTHON_REQ_FILE = /tmp/requirements.txt
DEMO_FILE = ./demo/app.py
TESTS_DIR = ./tests
DOCS_DIR = ./docs
.PHONY: help install install-quality ruff-lint ruff-lint-fix ruff-format ruff-format-fix lint-check lint-format precommit typing-check deps-check quality style init-gh-labels init-gh-settings install-mintlify start-mintlify
help: ## Show this help message
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
########################################################
# Install & Setup
########################################################
venv:
uv venv --python 3.11
install: ${PY_DIR} ${PYPROJECT_FILE} ## Install the core library
uv pip install -e ${PY_DIR}
########################################################
# Code checks
########################################################
install-quality: ${PY_DIR} ${PYPROJECT_FILE} ## Install with quality dependencies
uv pip install -e '${PY_DIR}[quality]'
ruff-lint: ${PYPROJECT_FILE} ## Check code linting
uv run --extra quality ruff check . --config ${PYPROJECT_FILE}
ruff-lint-fix: ${PYPROJECT_FILE} ## Fix code linting
uv run --extra quality ruff check --fix . --config ${PYPROJECT_FILE}
ruff-format: ${PYPROJECT_FILE} ## Check code formatting
uv run --extra quality ruff format --check . --config ${PYPROJECT_FILE}
ruff-format-fix: ${PYPROJECT_FILE} ## Fix code formatting
uv run --extra quality ruff format . --config ${PYPROJECT_FILE}
lint-check: ruff-lint ruff-format ## Check code formatting and linting
lint-format: ruff-lint-fix ruff-format-fix ## Format code and fix linting issues
precommit: ${PYPROJECT_FILE} .pre-commit-config.yaml ## Run pre-commit hooks
uv run --extra quality prek run --all-files
typing-check: ${PYPROJECT_FILE} ## Check type annotations
uv run --extra quality ty check .
deps-check: .github/verify_deps_sync.py ## Check dependency synchronization
uv run --script .github/verify_deps_sync.py
# this target runs checks on all files
quality: lint-check typing-check deps-check ## Run all quality checks
style: precommit ## Format code and run pre-commit hooks
########################################################
# Builds
########################################################
set-version: ${PYPROJECT_FILE} ## Set the version in the pyproject.toml file
uv version --frozen --no-build ${BUILD_VERSION}
build: ${PYPROJECT_FILE} ## Build the package
uv build ${PY_DIR}
publish: ${PY_DIR} ## Publish the package to PyPI
uv publish --trusted-publishing always
########################################################
# Tests
########################################################
install-test: ${PY_DIR} ${PYPROJECT_FILE} ## Install with test dependencies
uv pip install -e '${PY_DIR}[test]'
test: ${PYPROJECT_FILE} ## Run the tests
uv run pytest --cov-report xml
########################################################
# Docs
########################################################
install-docs: ${PYPROJECT_FILE}
uv pip install -e ".[docs]"
# Build documentation for current version
serve-docs: ${DOCS_DIR}
DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib uv run mkdocs serve -f ${DOCS_DIR}/mkdocs.yml
# Check that docs can build
build-docs: ${DOCS_DIR}
DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib uv run mkdocs build -f ${DOCS_DIR}/mkdocs.yml
push-docs: ${DOCS_DIR}
DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib uv run mkdocs gh-deploy -f ${DOCS_DIR}/mkdocs.yml --force
########################################################
# Demo
########################################################
install-demo: ${PYPROJECT_FILE}
uv pip install -e ".[demo]"
# Run the Gradio demo
run-demo: ${DEMO_FILE}
uv run streamlit run ${DEMO_FILE}
########################################################
# Local setup
########################################################
# Push secrets to GH for deployment
push-secrets: .env
gh secret set -f .env --app actions
gh secret set -f .env --app dependabot
gh secret set -f .env --app codespaces