-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
136 lines (104 loc) · 3.4 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
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
###############################################################################
# Common make values.
lib := par_gpt
run := uv run
python := $(run) python
pyright := $(run) pyright
ruff := $(run) ruff
twine := $(run) twine
#build := $(python) -m build
build := uvx --from build pyproject-build --installer uv
#export UV_LINK_MODE=copy
export PIPENV_VERBOSITY=-1
##############################################################################
# Run the app.
.PHONY: app_help
app_help: # Show app help
$(run) $(lib) --help
##############################################################################
.PHONY: uv-lock
uv-lock:
uv lock
.PHONY: uv-sync
uv-sync:
uv sync
.PHONY: setup
setup: uv-lock uv-sync # use this for first time run
.PHONY: resetup
resetup: remove-venv setup # Recreate the virtual environment from scratch
.PHONY: remove-venv
remove-venv: # Remove the virtual environment
rm -rf .venv
.PHONY: depsupdate
depsupdate: # Update all dependencies
uv sync -U
.PHONY: depsshow
depsshow: # Show the dependency graph
uv tree
.PHONY: shell
shell: # Start shell inside of .venv
$(run) bash
.PHONY: sandbox
sandbox: # start code sandbox container
cd sandbox && docker compose -p par_gpt_sandbox up -d --build --force-recreate
##############################################################################
# Checking/testing/linting/etc.
.PHONY: format
format: # Reformat the code with ruff.
$(ruff) format src/
.PHONY: lint
lint: # Run ruff lint over the library
$(ruff) check src/ --fix
.PHONY: lint-unsafe
lint-unsafe: # Run ruff lint over the library
$(ruff) check src/ --fix --unsafe-fixes
.PHONY: typecheck
typecheck: # Perform static type checks with pyright
$(pyright)
.PHONY: typecheck-stats
typecheck-stats: # Perform static type checks with pyright and print stats
$(pyright) --stats
.PHONY: checkall
checkall: format lint typecheck # Check all the things
.PHONY: pre-commit # run pre-commit checks on all files
pre-commit:
pre-commit run --all-files
.PHONY: pre-commit-update # run pre-commit and update hooks
pre-commit-update:
pre-commit autoupdate
##############################################################################
# Package/publish.
.PHONY: package
package: # Package the library
$(build) -w
.PHONY: spackage
spackage: # Create a source package for the library
$(build) -s
.PHONY: packagecheck
packagecheck: clean package spackage # Check the packaging.
$(twine) check dist/*
.PHONY: testdist
testdist: packagecheck # Perform a test distribution
$(twine) upload --repository testpypi dist/*
#$(twine) upload --skip-existing --repository testpypi dist/*
.PHONY: dist
dist: packagecheck # Upload to pypi
$(twine) upload --skip-existing dist/*
##############################################################################
# Utility.
.PHONY: repl
repl: # Start a Python REPL
$(python)
.PHONY: clean
clean: # Clean the build directories
rm -rf build dist $(lib).egg-info
.PHONY: help
help: # Display this help
@grep -Eh "^[a-z]+:.+# " $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.+# "}; {printf "%-20s %s\n", $$1, $$2}'
##############################################################################
# Housekeeping tasks.
.PHONY: housekeeping
housekeeping: # Perform some git housekeeping
git fsck
git gc --aggressive
git remote update --prune