a b/Makefile
1
.PHONY: clean clean-build clean-pyc clean-test coverage dist docs help install lint lint/flake8 lint/black
2
.DEFAULT_GOAL := help
3
4
define BROWSER_PYSCRIPT
5
import os, webbrowser, sys
6
7
from urllib.request import pathname2url
8
9
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
10
endef
11
export BROWSER_PYSCRIPT
12
13
define PRINT_HELP_PYSCRIPT
14
import re, sys
15
16
for line in sys.stdin:
17
    match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
18
    if match:
19
        target, help = match.groups()
20
        print("%-20s %s" % (target, help))
21
endef
22
export PRINT_HELP_PYSCRIPT
23
24
BROWSER := python -c "$$BROWSER_PYSCRIPT"
25
26
help:
27
    @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
28
29
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
30
31
clean-build: ## remove build artifacts
32
    rm -fr build/
33
    rm -fr dist/
34
    rm -fr .eggs/
35
    find . -name '*.egg-info' -exec rm -fr {} +
36
    find . -name '*.egg' -exec rm -f {} +
37
38
clean-pyc: ## remove Python file artifacts
39
    find . -name '*.pyc' -exec rm -f {} +
40
    find . -name '*.pyo' -exec rm -f {} +
41
    find . -name '*~' -exec rm -f {} +
42
    find . -name '__pycache__' -exec rm -fr {} +
43
44
clean-test: ## remove test and coverage artifacts
45
    rm -fr .tox/
46
    rm -f .coverage
47
    rm -fr htmlcov/
48
    rm -fr .pytest_cache
49
50
lint/flake8: ## check style with flake8
51
    flake8 wsic tests
52
lint/black: ## check style with black
53
    black --check wsic tests
54
55
lint: lint/flake8 lint/black ## check style
56
57
test: ## run tests quickly with the default Python
58
    pytest
59
60
test-all: ## run tests on every Python version with tox
61
    tox
62
63
coverage: ## check code coverage quickly with the default Python
64
    pytest
65
    $(BROWSER) htmlcov/index.html
66
67
host-coverage coverage: ## Simple HTTP server for hosting coverage
68
    cd coverage && python -m http.server 8888
69
70
docs: ## generate Sphinx HTML documentation, including API docs
71
    rm -f docs/wsic.rst
72
    rm -f docs/modules.rst
73
    $(MAKE) -C docs clean
74
    sphinx-apidoc -o docs/ wsic
75
    $(MAKE) -C docs html
76
    $(BROWSER) docs/_build/html/index.html
77
78
servedocs: docs ## compile the docs watching for changes
79
    watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
80
81
release: dist ## package and upload a release
82
    twine upload dist/*
83
84
dist: clean ## builds source and wheel package
85
    python setup.py sdist
86
    python setup.py bdist_wheel
87
    ls -l dist
88
89
install: clean ## install the package to the active Python's site-packages
90
    python setup.py install