-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython.mk
More file actions
68 lines (49 loc) · 1.33 KB
/
Python.mk
File metadata and controls
68 lines (49 loc) · 1.33 KB
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
# russellane/Python.mk
VENV ?= .venv
build:: venv tags lint test doc dist
lint:: ruff
test:: pytest
doc:: ;
dist::
pdm build
PROJECT_NAME := $(shell sed -ne 's/^name = "\(.*\)"$$/\1/p' pyproject.toml)
.PHONY: venv
venv: $(VENV)
$(VENV):
pdm install
.PHONY: tags
tags::
ctags -R $(PROJECT) tests $(VENV)
ruff::
pdm run ruff format $(PROJECT) tests
pdm run ruff check --fix $(PROJECT) tests
mypy::
pdm run mypy $(PROJECT) tests
# coverage fail_under is set in pyproject.toml [tool.coverage.report]
PYTEST = pdm run pytest $(PYTESTOPTS) \
--cov=$(PROJECT) --cov-report=html \
--exitfirst --showlocals --verbose
pytest::
$(PYTEST) tests
pytest_debug::
$(PYTEST) --capture=no tests
coverage::
pdm run pytest --cov=$(PROJECT) tests
install::
-pipx uninstall $(PROJECT_NAME)
pipx install .
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/*
clean::
rm -rf .coverage .mypy_cache .pdm-build .pytest_cache $(VENV) 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:
pdm run python -m $(PROJECT) --md-help >$@
# vim: set ts=8 sw=8 noet: