-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmakefile
More file actions
141 lines (111 loc) · 3.18 KB
/
makefile
File metadata and controls
141 lines (111 loc) · 3.18 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
PACKAGE_SLUG=celerpy
ifdef CI
PYENV_TARGET:=
PYENV_PYTHON=python
PYTHON_VERSION:=$(shell $(PYENV_PYTHON) --version|cut -d" " -f2)
else
PYENV_TARGET:=pyenv
PYENV_PYTHON:=pyenv exec python
PYTHON_VERSION:=$(shell cat .python-version)
endif
ifeq ($(USE_SYSTEM_PYTHON), true)
PYTHON_PACKAGE_PATH:=$(shell $(PYENV_PYTHON) -c "import sys; print(sys.path[-1])")
PYTHON_ENV:=
VENV_TARGET:=
else
PYTHON_SHORT_VERSION:=$(shell echo $(PYTHON_VERSION) | grep -o '[0-9].[0-9]*')
PYTHON_PACKAGE_PATH:=.venv/lib/python$(PYTHON_SHORT_VERSION)/site-packages
PYTHON_ENV:= . .venv/bin/activate &&
VENV_TARGET:= .venv
endif
PYTHON:=$(PYTHON_ENV) python
# Used to confirm that pip has run at least once
BUILD_DIR:=$(PYTHON_PACKAGE_PATH)/build
.PHONY: all
all: $(PYENV_TARGET) $(BUILD_DIR)
.PHONY: install
install: $(PYENV_TARGET) $(VENV_TARGET) pip
.PHONY: pyenv
pyenv:
pyenv install --skip-existing $(PYTHON_VERSION)
.venv:
$(PYENV_PYTHON) -m venv .venv
# Note that CI is defined when running through github actions
.PHONY: pip
pip: $(VENV_TARGET) pip-install
.PHONY: pip-install
pip-install:
ifdef CI
$(PYTHON) -m pip install -r requirements-dev.txt
else
$(PYTHON) -m pip install -e .[dev]
endif
$(BUILD_DIR): $(VENV_TARGET) pip-install
.PHONY: pre-commit
pre-commit: $(BUILD_DIR)
$(PYTHON_ENV) pre-commit install
#
# Formatting
#
.PHONY: style
style: style/format style/check style/dapperdata style/tomlsort
# NOTE: formatting must occur before style check
.PHONY: style/format
style/format:
$(PYTHON) -m ruff format .
.PHONY: style/check
style/check:
$(PYTHON) -m ruff check . --fix
.PHONY: style/dapperdata
style/dapperdata:
$(PYTHON) -m dapperdata.cli pretty . --no-dry-run
.PHONY: style/tomlsort
style/tomlsort:
$(PYTHON_ENV) toml-sort $$(find . -not -path "./.venv/*" -name "*.toml") -i
#
# Testing
#
.PHONY: test
test: $(BUILD_DIR) test/all
.PHONY: test/all
test/all: test/pytest test/ruff test/black test/mypy test/dapperdata test/tomlsort
.PHONY: test/pytest
test/pytest:
$(PYTHON) -m pytest --cov=./${PACKAGE_SLUG} --cov-report=term-missing test
.PHONY: test/pytest-loud
test/pytest-loud:
$(PYTHON) -m pytest -s --cov=./${PACKAGE_SLUG} --cov-report=term-missing test
.PHONY: test/ruff
test/ruff:
$(PYTHON) -m ruff check
.PHONY: test/black
test/black:
$(PYTHON) -m ruff format . --check
.PHONY: test/mypy
test/mypy:
$(PYTHON) -m mypy ${PACKAGE_SLUG}
.PHONY: test/dapperdata
test/dapperdata:
$(PYTHON) -m dapperdata.cli pretty .
.PHONY: test/tomlsort
test/tomlsort:
$(PYTHON_ENV) toml-sort $$(find . -not -path "./.venv/*" -name "*.toml") --check
#
# Dependencies
#
.PHONY: rebuild_dependencies
rebuild_dependencies:
$(PYTHON) -m uv pip compile --output-file=requirements.txt pyproject.toml
$(PYTHON) -m uv pip compile --output-file=requirements-dev.txt --extra=dev pyproject.toml
.PHONY: dependencies
dependencies: requirements.txt requirements-dev.txt
requirements.txt: $(BUILD_DIR) pyproject.toml
$(PYTHON) -m uv pip compile --upgrade --output-file=requirements.txt pyproject.toml
requirements-dev.txt: $(BUILD_DIR) pyproject.toml
$(PYTHON) -m uv pip compile --upgrade --output-file=requirements-dev.txt --extra=dev pyproject.toml
#
# Packaging
#
.PHONY: build
build: $(BUILD_DIR)
$(PYTHON) -m build