-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
96 lines (68 loc) · 2.49 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
88
89
90
91
92
93
94
95
96
.PHONY: help clean test coverage docs servedocs install
.DEFAULT_GOAL := help
define BROWSER_PYSCRIPT
import os, webbrowser, sys
from urllib.request import pathname2url
rel_current_path = sys.argv[1]
abs_current_path = os.path.abspath(rel_current_path)
uri = "file://" + pathname2url(abs_current_path)
webbrowser.open(uri)
endef
export BROWSER_PYSCRIPT
define PRINT_HELP_PYSCRIPT
import re, sys
regex_pattern = r'^([a-zA-Z_-]+):.*?## (.*)$$'
for line in sys.stdin:
match = re.match(regex_pattern, line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"
DO_DOCS_HTML := $(MAKE) -C clean-docs && $(MAKE) -C docs html
SPHINXBUILD = python3 -msphinx
PACKAGE_NAME = "spycio"
PACKAGE_VERSION := poetry version -s
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
clean: clean-build clean-pyc clean-test clean-cache clean-docs ## remove all build, test, coverage, Python artifacts, cache and docs
clean-docs: # remove docs for update
rm -fr "docs/$$PACKAGE_NAME.rst" "docs/modules.rst" "docs/conftest.rst" "docs/examples.rst" "docs/tests.rst" "docs/_build"
clean-build: # remove build artifacts
rm -fr build/ dist/ .eggs/
find . -name '*.egg-info' -o -name '*.egg' -exec rm -fr {} +
clean-pyc: # remove Python file artifacts
find . -name '*.pyc' -o -name '*.pyo' -o -name '*~' -exec rm -rf {} +
clean-test: # remove test and coverage artifacts
rm -fr .tox/ .coverage coverage.* htmlcov/ .pytest_cache
clean-cache: # remove test and coverage artifacts
find . -name '*cache*' -exec rm -rf {} +
test: ## run tests quickly with the default Python
poetry shell
pytest
watch: ## run tests on watchdog mode
poetry shell
ptw
lint: clean ## perform inplace lint fixes
ruff --fix .
pre-commit run --all-files
coverage: clean ## check code coverage quickly with the default Python
pytest --cov-report term-missing --cov="$(PACKAGE_NAME)" tests/
install: clean ## install the package to the active Python's site-packages
poetry shell
poetry install
echo: ## echo current package version
echo "v$$(poetry version -s)"
bump: ## bump version to user-provided {patch|minor|major} semantic
poetry version $(v)
git add pyproject.toml
git commit -m "release/ tag v$$(poetry version -s)"
git tag "v$$(poetry version -s)"
git push
git push --tags
poetry version
publish: clean ## build source and publish package
poetry publish --build
release: bump v=$(v) ## release package on PyPI
poetry publish --build