|
1 |
| -.PHONY: test |
| 1 | +.PHONY: test # Declare the 'test' target as phony to avoid conflicts with files named 'test' |
2 | 2 |
|
| 3 | +# Variables to store the paths of the python, pip, pytest, and ruff executables |
| 4 | +PYTHON := $(shell which python) |
| 5 | +PIP := $(shell which pip) |
| 6 | +PYTEST := $(shell which pytest) |
| 7 | +RUFF := $(shell which ruff) |
| 8 | + |
| 9 | +# Target to create a Python virtual environment |
3 | 10 | .venv:
|
4 |
| - python3 -m venv .venv |
| 11 | + $(PYTHON) -m venv $(shell dirname $(PYTHON)) |
5 | 12 |
|
| 13 | +# Target to install development dependencies in the virtual environment |
6 | 14 | install_dev: .venv
|
7 |
| - .venv/bin/pip install -e ".[test]" |
| 15 | + $(PIP) install -e ".[test]" |
8 | 16 |
|
| 17 | +# Target to run tests with pytest, using 2 parallel processes and only non-marked tests |
9 | 18 | test: .venv
|
10 |
| - .venv/bin/pytest -v -rsx -n 2 tests/ --non-marked-only |
| 19 | + $(PYTEST) -v -rsx -n 2 tests/ --non-marked-only |
11 | 20 |
|
| 21 | +# Target to run all tests with pytest, including slow tests, using 2 parallel processes |
12 | 22 | test_all: .venv
|
13 |
| - RUN_SLOW=1 .venv/bin/pytest -v -rsx -n 2 tests/ |
| 23 | + RUN_SLOW=1 $(PYTEST) -v -rsx -n 2 tests/ |
14 | 24 |
|
| 25 | +# Target to generate a table by running a Python script |
15 | 26 | table:
|
16 |
| - .venv/bin/python misc/generate_table.py |
| 27 | + $(PYTHON) misc/generate_table.py |
17 | 28 |
|
| 29 | +# Target to generate a table for timm by running a Python script |
18 | 30 | table_timm:
|
19 |
| - .venv/bin/python misc/generate_table_timm.py |
| 31 | + $(PYTHON) misc/generate_table_timm.py |
20 | 32 |
|
| 33 | +# Target to fix and format code using ruff |
21 | 34 | fixup:
|
22 |
| - .venv/bin/ruff check --fix |
23 |
| - .venv/bin/ruff format |
| 35 | + $(RUFF) check --fix |
| 36 | + $(RUFF) format |
24 | 37 |
|
| 38 | +# Target to run code formatting and tests |
25 | 39 | all: fixup test
|
26 |
| - |
|
0 commit comments