-
Notifications
You must be signed in to change notification settings - Fork 1
/
Python.mk
72 lines (52 loc) · 1.43 KB
/
Python.mk
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
# russellane/Python.mk
build:: __pypackages__ tags lint test doc
pdm build
lint:: black isort flake8
test:: pytest
doc:: ;
bump_micro:: _bump_micro clean build
_bump_micro:
pdm bump micro
publish_local::
cd dist; echo *.whl | cpio -pdmuv `pip config get global.find-links`
publish_test::
twine upload --verbose -r testpypi dist/*
publish_prod::
twine upload --verbose -r pypi dist/*
PROJECT_NAME := $(shell sed -ne 's/^name = "\(.*\)"$$/\1/p' pyproject.toml)
install::
-pipx uninstall $(PROJECT_NAME)
pipx install $(PROJECT_NAME)
__pypackages__:
pdm install
.PHONY: tags
tags::
ctags -R $(PROJECT) tests __pypackages__
black::
python -m black -q $(PROJECT) tests
isort::
python -m isort $(PROJECT) tests
flake8::
python -m flake8 $(PROJECT) tests
mypy::
python -m mypy $(PROJECT) tests
COV_FAIL_UNDER = 0
PYTEST = python -m pytest $(PYTESTOPTS) \
--cov=$(PROJECT) --cov-report=html \
--cov-fail-under $(COV_FAIL_UNDER) \
--exitfirst --showlocals --verbose
pytest::
$(PYTEST) tests
pytest_debug::
$(PYTEST) --capture=no tests
coverage::
python -m pytest --cov=$(PROJECT) tests
clean::
rm -rf .coverage .mypy_cache .pdm-build .pytest_cache __pypackages__ dist htmlcov tags
find . -type f -name '*.py[co]' -delete
find . -type d -name __pycache__ -delete
# put `doc :: README.md` into Makefile, if desired
.PHONY: README.md
README.md:
python -m $(PROJECT) --md-help >$@
# vim: set ts=8 sw=8 noet: