-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
210 lines (187 loc) · 6.32 KB
/
Makefile
File metadata and controls
210 lines (187 loc) · 6.32 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
.PHONY: help clean install dev-install test test-cov test-integration lint format format-check check build sdist wheel docs html clean-docs upload upload-test check-package
# Use uv if available, otherwise fall back to pip
UV := $(shell command -v uv 2>/dev/null)
ifeq ($(UV),)
PIP_CMD = pip
PYTHON_CMD = python
else
PIP_CMD = uv pip
PYTHON_CMD = uv run python
# dev group is installed by default with uv sync
UV_SYNC = uv sync --group docs
endif
help:
@echo "Available targets:"
@echo ""
@echo "Setup (run first):"
@echo " dev-install - Install package with development dependencies (recommended for active development)"
@echo " setup-venv - Create virtual environment and install dependencies only (no package install)"
@echo " Use for: CI/CD, code review, or when you don't need to import the package"
@echo " install - Install the package (after setup-venv or standalone)"
@echo ""
@echo "Testing:"
@echo " test - Run all unit tests (excludes integration tests)"
@echo " test-cov - Run tests with coverage report"
@echo " test-integration - Run integration tests (requires running NoxRunner backend)"
@echo ""
@echo "Code Quality:"
@echo " lint - Run linting checks (ruff)"
@echo " format - Format code with ruff"
@echo " format-check - Check code formatting"
@echo " check - Run all checks (lint + format check + tests)"
@echo ""
@echo "Building:"
@echo " build - Build source and wheel distributions"
@echo " sdist - Build source distribution"
@echo " wheel - Build wheel distribution"
@echo " check-package - Check package before uploading"
@echo ""
@echo "Publishing:"
@echo " upload - Upload package to PyPI (requires PYPI_TOKEN env var)"
@echo " upload-test - Upload package to TestPyPI (requires TEST_PYPI_TOKEN env var)"
@echo ""
@echo "Documentation:"
@echo " docs - Build documentation"
@echo " html - Build HTML documentation"
@echo ""
@echo "Cleanup:"
@echo " clean - Clean build artifacts"
@echo " clean-docs - Clean documentation build"
@echo ""
@if [ -n "$(UV)" ]; then \
echo "Using uv for dependency management"; \
else \
echo "Using pip for dependency management (consider installing uv: curl -LsSf https://astral.sh/uv/install.sh | sh)"; \
fi
@echo ""
@echo "Note: For active development, run 'make dev-install' (installs package + deps)."
@echo " For CI/tools only, run 'make setup-venv' (deps only, no package)."
setup-venv:
@echo "Setting up virtual environment and installing dependencies (without installing package)..."
@echo "This is useful for CI/CD, code review, or when you only need development tools."
@if [ -n "$(UV)" ]; then \
uv sync --group docs --no-install-project; \
echo "✅ Virtual environment created and dependencies installed!"; \
echo " To install the package later, run: make install"; \
echo " Note: Some tests may fail without the package installed."; \
else \
echo "Error: uv is required for setup-venv. Install uv or use 'make dev-install' instead."; \
exit 1; \
fi
install:
@if [ -n "$(UV)" ]; then \
uv sync; \
else \
$(PIP_CMD) install -e .; \
fi
dev-install:
@echo "Installing package with all development dependencies..."
@if [ -n "$(UV)" ]; then \
uv sync --group docs; \
else \
$(PIP_CMD) install -e ".[dev]"; \
fi
@echo "✅ Package and dependencies installed! Ready for development."
test:
@echo "Running unit tests (excluding integration tests)..."
$(PYTHON_CMD) -m pytest tests/ -v -m "not integration"
test-cov:
$(PYTHON_CMD) -m pytest tests/ -m "not integration" --cov=noxrunner --cov-report=html --cov-report=term
test-integration:
@echo "Running integration tests (requires running NoxRunner backend)..."
@echo "Make sure NOXRUNNER_BASE_URL is set (default: http://127.0.0.1:8080)"
@echo ""
@if [ -z "$$NOXRUNNER_BASE_URL" ]; then \
echo "Using default base URL: http://127.0.0.1:8080"; \
echo "Set NOXRUNNER_BASE_URL to use a different backend"; \
fi
NOXRUNNER_ENABLE_INTEGRATION=1 $(PYTHON_CMD) -m pytest tests/ -v -m integration
lint:
$(PYTHON_CMD) -m ruff check noxrunner/ tests/ examples/ --output-format=concise
format:
$(PYTHON_CMD) -m ruff format noxrunner/ tests/ examples/
format-check:
$(PYTHON_CMD) -m ruff format --check noxrunner/ tests/ examples/
check: lint format-check test
@echo "All checks passed!"
build: clean
@if [ -n "$(UV)" ]; then \
uv sync --group docs; \
fi
$(PYTHON_CMD) -m build
sdist: clean
@if [ -n "$(UV)" ]; then \
uv sync --group docs; \
fi
$(PYTHON_CMD) -m build --sdist
wheel: clean
@if [ -n "$(UV)" ]; then \
uv sync --group docs; \
fi
$(PYTHON_CMD) -m build --wheel
check-package: build
@echo "Checking package..."
@if [ -n "$(UV)" ]; then \
uv pip install twine; \
else \
$(PIP_CMD) install twine; \
fi
twine check dist/*
upload: check-package
@echo "Uploading to PyPI..."
@if [ -z "$$PYPI_TOKEN" ]; then \
echo "Error: PYPI_TOKEN environment variable is not set."; \
echo "Usage: PYPI_TOKEN=your-token make upload"; \
exit 1; \
fi
@if [ -n "$(UV)" ]; then \
uv pip install twine; \
else \
$(PIP_CMD) install twine; \
fi
twine upload dist/* \
--username __token__ \
--password $$PYPI_TOKEN
upload-test: check-package
@echo "Uploading to TestPyPI..."
@if [ -z "$$TEST_PYPI_TOKEN" ]; then \
echo "Error: TEST_PYPI_TOKEN environment variable is not set."; \
echo "Usage: TEST_PYPI_TOKEN=your-token make upload-test"; \
exit 1; \
fi
@if [ -n "$(UV)" ]; then \
uv pip install twine; \
else \
$(PIP_CMD) install twine; \
fi
twine upload dist/* \
--repository testpypi \
--username __token__ \
--password $$TEST_PYPI_TOKEN
docs:
@if [ -n "$(UV)" ]; then \
uv sync --group docs; \
fi
cd docs && $(PYTHON_CMD) -m sphinx -M html source build
html:
@if [ -n "$(UV)" ]; then \
uv sync --group docs; \
fi
cd docs && $(PYTHON_CMD) -m sphinx -M html source build
clean:
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
rm -rf .pytest_cache
rm -rf .mypy_cache
find . -type d -name __pycache__ -exec rm -r {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
@if [ -n "$(UV)" ]; then \
echo "Note: To clean uv virtual environment, run: uv venv --clear"; \
fi
clean-docs:
@if [ -d "docs" ]; then \
cd docs && make clean; \
else \
echo "Documentation directory not found. Skipping..."; \
fi