-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
107 lines (85 loc) · 2.84 KB
/
Makefile
File metadata and controls
107 lines (85 loc) · 2.84 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
# Copyright 2024-2025 Olivier Romain, Francis Blais, Vincent Girouard, Marius Trudeau
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Detect the operating system
ifeq ($(OS), Windows_NT)
DETECTED_OS := Windows
else
DETECTED_OS := $(shell uname -s)
endif
# Set platform-specific commands
ifeq ($(DETECTED_OS), Windows)
PYTHON := $(shell where py 2>NUL || where py3 2>NUL || where python 2>NUL || where python3 2>NUL)
OPEN := cmd /c start
RMFILES := del /q
RMDIR := rmdir /s /q
else
PYTHON := $(shell which py 2>/dev/null || which py3 2>/dev/null || which python 2>/dev/null || which python3 2>/dev/null)
OPEN := open
RMFILES := rm -f
RMDIR := rm -rf
endif
# Directories
SRC_DIR := src
DOCS_DIR := docs
TEST_DIR := tests
BENCHMARK_DIR := benchmarks
# Set the default goal
.DEFAULT_GOAL := help
SPACE := $(empty) $(empty)
# Show available targets
.PHONY: help
help:
@$(info Available targets:)
@$(info $(SPACE) docs - Build documentation)
@$(info $(SPACE) format - Format source and test code using isort and black)
@$(info $(SPACE) test - Run tests)
@$(info $(SPACE) test_cov - Run tests with coverage)
@$(info $(SPACE) test_report - Open coverage report)
@$(info $(SPACE) run_benchmarks - Run benchmarks for all versions skipping existing profiles)
@$(info $(SPACE) show_benchmarks - Show benchmark results)
@$(info $(SPACE) clean - Remove coverage artifacts)
# Generate the documentation
.PHONY: docs
docs:
$(MAKE) -C $(DOCS_DIR) figures
$(MAKE) -C $(DOCS_DIR) html
# Format the code with black and isort
.PHONY: format
format:
$(PYTHON) -m isort $(SRC_DIR) $(TEST_DIR) $(BENCHMARK_DIR)
$(PYTHON) -m black $(SRC_DIR) $(TEST_DIR) $(BENCHMARK_DIR) -l 100
# Run the tests
.PHONY: test
test:
$(PYTHON) -m pytest $(TEST_DIR) -n auto
# Run the tests with coverage
.PHONY: test_cov
test_cov:
$(PYTHON) -m pytest --cov=$(SRC_DIR) $(TEST_DIR) --cov-report=html --cov-branch -n auto
# Show the test coverage report
.PHONY: test_report
test_report:
$(OPEN) ./htmlcov/index.html
# Run the benchmarks
.PHONY: run_benchmarks
run_benchmarks:
$(MAKE) -C $(BENCHMARK_DIR) run_missing_versions
# Show the benchmark results
.PHONY: show_benchmarks
show_benchmarks:
$(MAKE) -C $(BENCHMARK_DIR) show_graphs
# Clean the repository
.PHONY: clean
clean:
$(RMDIR) htmlcov