1# simple makefile to simplify repetitive build env management tasks under posix
2
3# caution: testing won't work on windows, see README
4
5PYTHON ?= python
6CYTHON ?= cython
7PYTEST ?= pytest
8CTAGS ?= ctags
9
10# skip doctests on 32bit python
11BITS := $(shell python -c 'import struct; print(8 * struct.calcsize("P"))')
12
13all: clean inplace test
14
15clean-ctags:
16	rm -f tags
17
18clean: clean-ctags
19	$(PYTHON) setup.py clean
20	rm -rf dist
21
22in: inplace # just a shortcut
23inplace:
24	$(PYTHON) setup.py build_ext -i
25
26test-code: in
27	$(PYTEST) --showlocals -v sklearn --durations=20
28test-sphinxext:
29	$(PYTEST) --showlocals -v doc/sphinxext/
30test-doc:
31ifeq ($(BITS),64)
32	$(PYTEST) $(shell find doc -name '*.rst' | sort)
33endif
34test-code-parallel: in
35	$(PYTEST) -n auto --showlocals -v sklearn --durations=20
36
37test-coverage:
38	rm -rf coverage .coverage
39	$(PYTEST) sklearn --showlocals -v --cov=sklearn --cov-report=html:coverage
40test-coverage-parallel:
41	rm -rf coverage .coverage .coverage.*
42	$(PYTEST) sklearn -n auto --showlocals -v --cov=sklearn --cov-report=html:coverage
43
44test: test-code test-sphinxext test-doc
45
46trailing-spaces:
47	find sklearn -name "*.py" -exec perl -pi -e 's/[ \t]*$$//' {} \;
48
49cython:
50	python setup.py build_src
51
52ctags:
53	# make tags for symbol based navigation in emacs and vim
54	# Install with: sudo apt-get install exuberant-ctags
55	$(CTAGS) --python-kinds=-i -R sklearn
56
57doc: inplace
58	$(MAKE) -C doc html
59
60doc-noplot: inplace
61	$(MAKE) -C doc html-noplot
62
63code-analysis:
64	flake8 sklearn | grep -v __init__ | grep -v external
65	pylint -E -i y sklearn/ -d E1103,E0611,E1101
66
67flake8-diff:
68	git diff upstream/main -u -- "*.py" | flake8 --diff
69