-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
131 lines (113 loc) · 2.82 KB
/
Makefile
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
# -*- mode: make; coding: utf-8 -*-
#!make
#
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
# All rights reserved.
# https://github.com/btschwertfeger
#
UV ?= uv
PYTHON := python
PYTEST := $(UV) run pytest
PYTEST_OPTS := -vv --junit-xml=pytest.xml
PYTEST_COV_OPTS := $(PYTEST_OPTS) --cov=kraken_infinity_grid --cov-report=xml:coverage.xml --cov-report=term-missing
TEST_DIR := tests
## ======= H E L P =============================================================
## help Show this help message
.PHONY: help
help:
@grep "^##" Makefile | sed -e "s/##//"
## ======= B U I L D I N G =====================================================
## build Builds the package
##
.PHONY: build
build: check-uv
$(UV) build .
.PHONY: rebuild
rebuild: clean build
## doc Build the documentation
##
.PHONY: doc
doc:
cd doc && make html
## ======= I N S T A L L A T I O N =============================================
## install Install the package
##
.PHONY: install
install: check-uv
$(UV) pip install .
## dev Installs the extended package in edit mode
##
.PHONY: dev
dev: check-uv
$(UV) pip install -e ".[dev,test,backtest]" -r doc/requirements.txt
## ======= T E S T I N G =======================================================
## test Run the unit tests
##
.PHONY: test
test:
$(PYTEST) $(PYTEST_OPTS) $(TEST_DIR)
.PHONY: tests
tests: test
## retest Run only the tests that failed last time
##
.PHONY: retest
retest:
$(PYTEST) $(PYTEST_OPTS) --lf $(TEST_DIR)
## wip Run tests marked as 'wip'
##
.PHONY: wip
wip:
@rm .cache/tests/*.log || true
$(PYTEST) -m "wip" -vv $(TEST_DIR)
## coverage Run all tests and generate the coverage report
##
.PHONY: coverage
coverage:
@rm .cache/tests/*.log || true
$(PYTEST) $(PYTEST_COV_OPTS) $(TEST_DIR)
## doctest Run the documentation related tests
##
.PHONY: doctest
doctest:
cd docs && make doctest
## ======= M I S C E L L A N I O U S ===========================================
## pre-commit Run the pre-commit targets
##
.PHONY: pre-commit
pre-commit:
@pre-commit run -a
## clean Clean the workspace
##
.PHONY: clean
clean:
rm -rf \
.cache \
.vscode \
dist/ \
doc/_build \
src/kraken_infinity_grid.egg-info \
build/
rm -f \
.coverage \
*.csv \
*.log \
*.zip \
coverage.xml \
src/kraken_infinity_grid/_version.py \
mypy.xml \
pytest.xml \
kraken_infinity_grid-*.whl \
uv.lock
find src/kraken_infinity_grid -name "__pycache__" | xargs rm -rf
find tests -name "__pycache__" | xargs rm -rf
find tools -name ".ipynb_checkpoints" | xargs rm -rf
find tools -name "__pycache__" | xargs rm -rf
find tests -name "*.log" | xargs rm -rf
## check-uv Check if uv is installed
##
.PHONY: check-uv
check-uv:
@if ! command -v $(UV) >/dev/null; then \
echo "Error: uv is not installed. Please visit https://github.com/astral-sh/uv for installation instructions."; \
exit 1; \
fi