forked from heywbj/django-rest-framework-recursive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
91 lines (70 loc) · 2.06 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
PIP_VERSION=24.0
SHELL=/bin/bash
# If we're running in CI then store Pytest output in a format which CircleCI can parse
ifdef CIRCLECI
MYPY_ARGS=--junit-xml=test-results/mypy.xml
endif
# Standard entry points
# =====================
.PHONY:dev
dev: install_python_packages .git/hooks/pre-commit
.PHONY:test
test:
pytest
.PHONY:matrix_test
matrix_test:
nox
.PHONY:lint
lint: ruff_format ruff_lint mypy
.PHONY:ruff_format
ruff_format:
ruff format --check .
.PHONY:ruff_lint
ruff_lint:
ruff check .
.PHONY:mypy
mypy:
mypy $(MYPY_ARGS)
.PHONY:format
format:
ruff format .
ruff check --fix .
.PHONY:update
update:
uv pip compile pyproject.toml -q --upgrade --extra=dev --output-file=requirements/development.txt
.PHONY:package
package:
python -m build
.PHONY:version_major
version_major:
bump-my-version bump major
.PHONY:version_minor
version_minor:
bump-my-version bump minor
.PHONY:version_patch
version_patch:
bump-my-version bump patch
# Implementation details
# ======================
# Pip install all required Python packages
.PHONY:install_python_packages
install_python_packages: install_prerequisites requirements/development.txt
uv pip sync requirements/development.txt requirements/firstparty.txt
# This target _could_ run `uv pip install` unconditionally because `uv pip
# install` is idempotent if versions have not changed. The benefits of checking
# the version number before installing are that if there's nothing to do then
# (a) it's faster and (b) it produces less noisy output.
.PHONY:install_prerequisites
install_prerequisites:
@if [ `uv pip show pip 2>/dev/null | awk '/^Version:/ {print $$2}'` != "$(PIP_VERSION)" ]; then \
uv pip install pip==$(PIP_VERSION); \
fi
# Add new dependencies to requirements/development.txt whenever pyproject.toml changes
requirements/development.txt: pyproject.toml
uv pip compile pyproject.toml -q --extra=dev --output-file=requirements/development.txt
.git/hooks/pre-commit:
@if type pre-commit >/dev/null 2>&1; then \
pre-commit install; \
else \
echo "WARNING: pre-commit not installed." > /dev/stderr; \
fi