Debian Codegraph @

Makefile

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