-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
87 lines (71 loc) · 2.41 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
OS := $(shell uname -s)
ifeq ($(OS), Linux)
NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
else ifeq ($(OS), Darwin)
NPROCS := 2
else
NPROCS := 0
endif # $(OS)
ifeq ($(NPROCS), 2)
CONCURRENCY := 2
else ifeq ($(NPROCS), 1)
CONCURRENCY := 1
else ifeq ($(NPROCS), 3)
CONCURRENCY := 3
else ifeq ($(NPROCS), 0)
CONCURRENCY := 0
else
CONCURRENCY := $(shell echo "$(NPROCS) 2" | awk '{printf "%.0f", $$1 / $$2}')
endif
# define python (if in venv, use python)
ifeq (, $(shell which python ))
PYTHON := python3
else
PYTHON := python
endif
.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " all to clean, check the style guidelines and run the test suite"
@echo " flake to check overall code style guidelines "
@echo " install to install qlearnkit"
@echo " test to run the test suite for all tested packages"
@echo " test-parallel to run the test suite for all tested packages in parallel"
@echo " coverage to generate a coverage report for all tested packages"
@echo " coverage-parallel to generate a coverage report for all tested packages in parallel"
@echo " doc to generate documentation for qlearnkit"
@echo " clean-doc to delete all built documentation"
@echo " apidoc to re-generate sphinx sources. Run ``make doc`` afterwards to build the documentation"
@echo " clean to delete all temporary, cache, and build files"
.PHONY: all flake install test test-parallel coverage coverage-parallel docs clean-doc apidoc clean
all: clean flake test-parallel
flake:
flake8 qlearnkit | grep -v __init__ | grep -v external
install:
$(PYTHON) setup.py install
test:
$(PYTHON) -m pytest
test-parallel:
echo "Detected $(NPROCS) CPUs running with $(CONCURRENCY) workers"
$(PYTHON) -m pytest -n $(CONCURRENCY)
coverage:
rm .coverage
$(PYTHON) -m pytest --cov=qlearnkit test/
coverage-parallel:
rm .coverage
$(PYTHON) -m pytest -n $(CONCURRENCY) --cov=qlearnkit test/
docs:
sphinx-build -M html docs docs/_build
clean-doc:
$(MAKE) -C docs clean
apidoc:
sphinx-apidoc -f -o docs/apidoc . setup.py */optionals.py */version.py
rm docs/apidoc/modules.rst
clean:
rm -rf __pycache__
rm -rf qlearnkit/__pycache__
rm -rf test/__pycache__
rm -rf dist
rm -rf build
rm -rf .pytest_cache
rm -rf .coverage coverage_html_report/