-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
106 lines (89 loc) · 3.2 KB
/
Copy pathMakefile
File metadata and controls
106 lines (89 loc) · 3.2 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
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
.PHONY: build install install-dev clean docs-clean docs-build docs-serve docs-deploy docs-set-default docs-list test test-unit test-integration mypy lint-imports
DOCS_DIR := build/docs
DOCS_BRANCH := gh-pages
TEST_LEVEL ?= L0
PUSH ?= true
PUSH_FLAG := $(if $(filter true,$(PUSH)),--push,)
build: clean
python3 -m build --wheel
install: build
pip3 install dist/*.whl
install-dev:
uv pip install --group dev -e .
clean: docs-clean
docs-clean:
rm -rf $(DOCS_DIR)
rm -rf site/ # Default mkdocs output dir (if someone runs mkdocs build directly)
# Build docs locally without versioning (for development/preview)
docs-build: docs-clean
mkdocs build --clean --site-dir $(DOCS_DIR)
# Serve docs locally for development
docs-serve:
mkdocs serve
# Deploy versioned docs using mike (for CI or manual release)
# Usage: make docs-deploy VERSION=v1.0.0 ALIAS=latest
# make docs-deploy VERSION=dev
# make docs-deploy VERSION=dev PUSH=false # Don't push (for CI)
docs-deploy:
ifndef VERSION
$(error VERSION is required. Usage: make docs-deploy VERSION=v1.0.0 ALIAS=latest)
endif
ifdef ALIAS
mike deploy --update-aliases $(VERSION) $(ALIAS) -b $(DOCS_BRANCH) $(PUSH_FLAG)
else
mike deploy $(VERSION) -b $(DOCS_BRANCH) $(PUSH_FLAG)
endif
# Set the default version for mike
# Usage: make docs-set-default VERSION=latest
# make docs-set-default VERSION=latest PUSH=false # Don't push (for CI)
docs-set-default:
ifndef VERSION
$(error VERSION is required. Usage: make docs-set-default VERSION=latest)
endif
mike set-default $(VERSION) -b $(DOCS_BRANCH) $(PUSH_FLAG)
# List all deployed doc versions
docs-list:
mike list -b $(DOCS_BRANCH)
test-integration:
@error=0; \
for dir in tests/integration/*/; do \
if [ -f "$${dir}test.sh" ] && [ "$$(echo $${dir} | grep -E "$(TEST_LEVEL)")" ]; then \
echo ""; \
echo "########################################"; \
echo "Setting up isolated venv for $${dir}"; \
echo "########################################"; \
echo ""; \
if [ ! -f "$${dir}requirements.txt" ]; then \
echo "Warning: $${dir}requirements.txt not found, skipping..."; \
continue; \
fi; \
if [ ! -d "$${dir}.venv" ]; then \
echo "Creating venv at $${dir}.venv"; \
python3 -m venv --copies $${dir}.venv || { error=1; continue; }; \
else \
echo "Using existing venv at $${dir}.venv"; \
fi; \
echo "Installing dependencies..."; \
( \
set -e; \
trap 'deactivate 2>/dev/null || true' EXIT; \
source $${dir}.venv/bin/activate && \
uv pip install --group test -e . -r $${dir}requirements.txt && \
echo "========================================"; \
echo "Running $${dir}test.sh"; \
echo "========================================"; \
echo ""; \
$${dir}test.sh \
) || error=1; \
fi; \
done; \
exit $$error
test-unit:
pytest -sv tests/unit --cov=flextensor --cov-report=html --cov-report=xml --cov-report=term-missing
mypy:
mypy src/flextensor
lint-imports:
PYTHONPATH=src uv run --no-project --with import-linter==2.12 lint-imports --config pyproject.toml --no-cache
test: test-integration test-unit