Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (59 loc) · 2.89 KB
/
Copy pathMakefile
File metadata and controls
62 lines (59 loc) · 2.89 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
# Prefer the repository's own virtualenv when it exists, so the targets work from an
# unactivated shell. `?=` still wins, so `make PYTHON=... ` and an activated venv both
# override it, and CI has no .venv so it falls through to python3 as before.
PYTHON ?= $(if $(wildcard .venv/bin/python),.venv/bin/python,python3)
.PHONY: init package publish ruff-check ruff-format ruff-fix lint format typecheck test test-all test-coverage clean benchmark benchmark-determinism benchmark-instructions profile-cpu profile-mem profile-flame
# Default profiling target fixture; override e.g. `make profile-cpu TARGET=komplex`
TARGET ?= asprox
# The setuptools range mirrors [build-system].requires in pyproject.toml, and has to: `make
# package` builds with --no-isolation, so the interpreter's own setuptools is the build backend.
# The floor is 77 because that is where the SPDX `license` expression emits valid metadata.
init:
$(PYTHON) -m pip install --upgrade pip "setuptools>=77,<84.1.0" "wheel>=0.47.0"
$(PYTHON) -m pip install -e ".[dev]"
$(PYTHON) -m pre_commit install
package:
rm -rf dist/*
$(PYTHON) -m build --no-isolation
publish:
$(PYTHON) -m twine upload dist/* -u __token__
ruff-check:
$(PYTHON) -m ruff check .
ruff-format:
$(PYTHON) -m ruff format .
ruff-fix:
$(PYTHON) -m ruff check . --fix
lint: ruff-check
format: ruff-format
# Paths must match the Code Quality job in .github/workflows/ci.yml
typecheck:
$(PYTHON) -m ty check src/smda/ fuzzing/ profiling/ .github/workflows/scripts/
# The `slow` tier is 124 of 2110 tests and roughly three quarters of the wall time, so the
# default target leaves it out to keep the edit-run loop short. CI always runs everything,
# and `make test-all` is the same thing locally -- run it before you push.
test:
$(PYTHON) -m pytest -m "not slow" tests/test*
test-all:
$(PYTHON) -m pytest tests/test*
test-coverage:
$(PYTHON) -m pytest --cov=smda --cov-report=html:coverage-html tests/
benchmark:
$(PYTHON) .github/workflows/scripts/run_perf_check.py --output benchmark_results.json
benchmark-determinism:
$(PYTHON) .github/workflows/scripts/run_perf_check.py --iterations 2 --call-counts --output benchmark_determinism.json
# Needs valgrind. Compare two trees with `count_instructions.py compare` (see profiling/README.md).
benchmark-instructions:
$(PYTHON) .github/workflows/scripts/count_instructions.py measure . --output instruction_counts/results.json
profile-cpu:
$(PYTHON) -m profiling.profile_smda cpu --target $(TARGET) --line
profile-mem:
$(PYTHON) -m profiling.profile_smda mem --target $(TARGET)
# py-spy needs sudo on macOS, and --native is Linux-only (see profiling/README.md).
profile-flame:
py-spy record --native -o profiling/output/$(TARGET).cpu.svg -- \
$(PYTHON) -m profiling.profile_smda run --target $(TARGET)
clean:
find . \( -name '__pycache__' -o -name '*.pyc' -o -name '*.pyo' \) -prune -exec rm -rf {} +
rm -rf .coverage
rm -rf coverage-html
rm -rf dist/*