Debian Codegraph @

Makefile

raw symbols SCIP
1 # Simple Makefile for use with a uv-based development environment
2 # The at (@) prefix tells make to suppress output from the command
3 # The hyphen (-) prefix tells make to ignore errors (e.g., if a directory doesn't exist)
4
5 .PHONY: install
6 install: ## Install the virtual environment with dependencies
7 @echo "🚀 Creating uv Python virtual environment"
8 @uv python install 3.14
9 @uv sync --python=3.14
10 @echo "🚀 Installing Git prek hooks locally"
11 @uv run prek install -f
12 @echo "🚀 Installing Prettier using npm"
13 @npm install -q --no-fund --include=dev
14
15 .PHONY: check
16 check: ## Run code quality tools.
17 @echo "🚀 Checking lock file consistency with 'pyproject.toml'"
18 @uv lock --locked
19 @echo "🚀 Auto-formatting/Linting code and documentation: Running prek"
20 @uv run prek run -a
21 @echo "🚀 Static type checking: Running mypy"
22 @uv run mypy
23
24 .PHONY: format
25 format: ## Perform ruff formatting
26 @uv run ruff format
27
28 .PHONY: lint
29 lint: ## Perform ruff linting
30 @uv run ruff check --fix
31
32 .PHONY: typecheck
33 typecheck: ## Perform type checking
34 @uv run mypy
35
36 .PHONY: test
37 test: ## Test the code with pytest.
38 @echo "🚀 Testing code: Running pytest"
39 @uv run python -Xutf8 -m pytest --cov --cov-config=pyproject.toml --cov-report=xml tests
40
41 .PHONY: docs-test
42 docs-test: ## Test if documentation can be built without warnings or errors
43 @uv run zensical build -s
44
45 .PHONY: docs
46 docs: ## Build and serve the documentation (and open in default browser)
47 @uv run zensical serve -o
48
49 .PHONY: build
50 build: clean-build ## Build wheel file
51 @echo "🚀 Creating wheel file"
52 @uv build
53
54 .PHONY: tag
55 tag: ## Add a Git tag and push it to origin with syntax: make tag TAG=tag_name
56 @echo "🚀 Creating git tag: ${TAG}"
57 @git tag -a ${TAG} -m ""
58 @echo "🚀 Pushing tag to origin: ${TAG}"
59 @git push origin ${TAG}
60
61 .PHONY: validate-tag
62 validate-tag: ## Check to make sure that a tag exists for the current HEAD and it looks like a valid version number
63 @echo "🚀 Validating version tag"
64 @uv run scripts/validate_tag.py
65
66 .PHONY: publish-test
67 publish-test: validate-tag build ## Test publishing a release to PyPI, uses token from ~/.pypirc file.
68 @echo "🚀 Publishing: Dry run."
69 @uv run uv-publish --repository testpypi
70
71 .PHONY: publish
72 publish: validate-tag build ## Publish a release to PyPI, uses token from ~/.pypirc file.
73 @echo "🚀 Publishing."
74 @uv run uv-publish
75
76 # Define variables for files/directories to clean
77 BUILD_DIRS = build dist *.egg-info
78 DOC_DIRS = build
79 MYPY_DIRS = .mypy_cache dmypy.json dmypy.sock
80 TEST_DIRS = .cache .pytest_cache htmlcov
81 TEST_FILES = .coverage coverage.xml
82
83 .PHONY: clean-build
84 clean-build: ## Clean build artifacts
85 @echo "🚀 Removing build artifacts"
86 @uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(BUILD_DIRS)'.split() if os.path.isdir(d)]"
87
88 .PHONY: clean-docs
89 clean-docs: ## Clean documentation artifacts
90 @echo "🚀 Removing documentation artifacts"
91 @uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(DOC_DIRS)'.split() if os.path.isdir(d)]"
92
93 .PHONY: clean-mypy
94 clean-mypy: ## Clean mypy artifacts
95 @echo "🚀 Removing mypy artifacts"
96 @uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(MYPY_DIRS)'.split() if os.path.isdir(d)]"
97
98 .PHONY: clean-pycache
99 clean-pycache: ## Clean pycache artifacts
100 @echo "🚀 Removing pycache artifacts"
101 @-find . -type d -name "__pycache__" -exec rm -r {} +
102
103 .PHONY: clean-ruff
104 clean-ruff: ## Clean ruff artifacts
105 @echo "🚀 Removing ruff artifacts"
106 @uv run ruff clean
107
108 .PHONY: clean-test
109 clean-test: ## Clean test artifacts
110 @echo "🚀 Removing test artifacts"
111 @uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(TEST_DIRS)'.split() if os.path.isdir(d)]"
112 @uv run python -c "from pathlib import Path; [Path(f).unlink(missing_ok=True) for f in '$(TEST_FILES)'.split()]"
113
114 .PHONY: clean
115 clean: clean-build clean-docs clean-mypy clean-pycache clean-ruff clean-test ## Clean all artifacts
116 @echo "🚀 Cleaned all artifacts"
117
118 .PHONY: help
119 help:
120 @uv run python -c "import re; \
121 [[print(f'\033[36m{m[0]:<20}\033[0m {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(makefile).read(), re.M)] for makefile in ('$(MAKEFILE_LIST)').strip().split()]"
122
123 .DEFAULT_GOAL := help