forked from mikemccand/luceneutil
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (60 loc) · 1.95 KB
/
Copy pathMakefile
File metadata and controls
77 lines (60 loc) · 1.95 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
# basic make safety: if error happens, delete output
.DELETE_ON_ERROR:
# explicitly declare shell used
SHELL := /bin/bash
# enforce that shell is picky
.SHELLFLAGS := -norc -euo pipefail -c
# don't litter up repo with bytecode
export PYTHONDONTWRITEBYTECODE=true
# don't self-check, don't ask questions
PIP_INSTALL_ARGS=--disable-pip-version-check --no-input --upgrade
# venv with dependencies in the standard location
VENV=${PWD}/.venv
# don't behave strangely if these files exist
.PHONY: lint format reformat tidy autofix ruff ruff-fix pyright env clean
# list of directories we check
SOURCES=src/python
# check formatting, linting, and types
lint: format ruff pyright
# check all formatting
format: env
# validate imports: if this fails, please run "make reformat" and commit changes.
$(VENV)/bin/ruff check --select I $(SOURCES)
# validate formatting: if this fails, please run "make reformat" and commit changes.
$(VENV)/bin/ruff format --diff $(SOURCES)
# alias for lucene gradle users!
tidy: reformat
# reformat code to conventions
reformat: env
# organize imports
$(VENV)/bin/ruff check --select I --fix $(SOURCES)
# reformat sources
$(VENV)/bin/ruff format $(SOURCES)
# applies all safe fixes, if successful reformats too
autofix: ruff-fix reformat
# applies safe autofixes
ruff-fix: env
# fix sources with ruff
$(VENV)/bin/ruff check --preview --fix $(SOURCES)
# lints sources
ruff: env
# validate sources with ruff linter
$(VENV)/bin/ruff check --preview $(SOURCES)
# checks types
pyright: env
# type-check sources with basedpyright
$(VENV)/bin/basedpyright $(SOURCES)
# rebuild venv if dependencies change
env: $(VENV)/bin/activate
$(VENV)/bin/activate: requirements.txt
# remove any existing venv
rm -rf $(VENV)
# create new venv
python3 -m venv $(VENV)
# install dependencies into venv
$(VENV)/bin/pip install $(PIP_INSTALL_ARGS) -r requirements.txt
# adjust timestamp for safety
touch $(VENV)/bin/activate
# nuke venv
clean:
rm -rf $(VENV)