|
| 1 | +.PHONY: clean clean-test clean-pyc clean-build docs help |
| 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 := python3 -c "$$BROWSER_PYSCRIPT" |
| 25 | +PROJECT := fuzzy_set |
| 26 | + |
| 27 | +help: |
| 28 | + @python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) |
| 29 | + |
| 30 | +clean: clean-doc 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 -fr {} + |
| 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 | + poetry run flake8 src tests |
| 53 | + |
| 54 | +test: ## run tests quickly with the default Python |
| 55 | + poetry run pytest |
| 56 | + |
| 57 | +test-all: ## run tests on every Python version with tox |
| 58 | + poetry run tox |
| 59 | + |
| 60 | +coverage: ## check code coverage quickly with the default Python |
| 61 | + poetry run coverage run -m pytest |
| 62 | + poetry run coverage html |
| 63 | + poetry run coverage xml |
| 64 | + $(BROWSER) htmlcov/index.html |
| 65 | + |
| 66 | +clean-doc: |
| 67 | + rm -rf docs/_build |
| 68 | + rm -rf docs/_autosummary |
| 69 | + rm -f docs/$(PROJECT).*.rst |
| 70 | + |
| 71 | +docs: clean-doc ## generate Sphinx HTML documentation, including API docs |
| 72 | + poetry run sphinx-apidoc -f -o docs/ src/ --separate |
| 73 | + poetry run sphinx-build -b html docs/ docs/_build/html |
| 74 | + $(BROWSER) docs/_build/html/index.html |
| 75 | + |
| 76 | +servedocs: docs ## compile the docs watching for changes |
| 77 | + watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . |
| 78 | + |
| 79 | +release: dist ## package and upload a release |
| 80 | + poetry publish |
| 81 | + |
| 82 | +dist: clean ## builds source and wheel package |
| 83 | + poetry build |
| 84 | + |
| 85 | +install: clean dist ## install the package to the active Python's site-packages |
| 86 | + pip3 install dist/*whl --break-system-packages --force-reinstall --no-deps |
0 commit comments