@@ -14,50 +14,45 @@ USE_MATURIN = $(shell [ "$$VIRTUAL_ENV" != "" ] && (which maturin))
14
14
.uv :
15
15
@uv -V || echo ' Please install uv: https://docs.astral.sh/uv/getting-started/installation/'
16
16
17
- .PHONY : .pre-commit # # Check that pre-commit is installed
18
- .pre-commit :
19
- @pre-commit -V || echo ' Please install pre-commit: https://pre-commit.com/'
20
-
21
- .PHONY : install
22
- install : .uv .pre-commit
23
- uv pip install -U wheel
17
+ .PHONY : install # # Install the package, dependencies, and pre-commit for local development
18
+ install : .uv
24
19
uv sync --frozen --group all
25
- uv pip install -v -e .
26
- pre-commit install
20
+ uv run pre-commit install --install-hooks
27
21
28
22
.PHONY : rebuild-lockfiles # # Rebuild lockfiles from scratch, updating all dependencies
29
23
rebuild-lockfiles : .uv
30
24
uv lock --upgrade
31
25
32
- .PHONY : install-rust-coverage
26
+ .PHONY : install-rust-coverage # # Install Rust coverage tools
33
27
install-rust-coverage :
34
28
cargo install rustfilt coverage-prepare
35
29
rustup component add llvm-tools-preview
36
30
37
- .PHONY : install-pgo
31
+ .PHONY : install-pgo # # Install Rust PGO tools
32
+ install-pgo :
38
33
rustup component add llvm-tools-preview
39
34
40
- .PHONY : build-dev
35
+ .PHONY : build-dev # # Build the development version of the package
41
36
build-dev :
42
37
@rm -f python/pydantic_core/* .so
43
38
uv run maturin develop --uv
44
39
45
- .PHONY : build-prod
40
+ .PHONY : build-prod # # Build the production version of the package
46
41
build-prod :
47
42
@rm -f python/pydantic_core/* .so
48
43
uv run maturin develop --uv --release
49
44
50
- .PHONY : build-profiling
45
+ .PHONY : build-profiling # # Build the profiling version of the package
51
46
build-profiling :
52
47
@rm -f python/pydantic_core/* .so
53
48
uv run maturin develop --uv --profile profiling
54
49
55
- .PHONY : build-coverage
50
+ .PHONY : build-coverage # # Build the coverage version of the package
56
51
build-coverage :
57
52
@rm -f python/pydantic_core/* .so
58
53
RUSTFLAGS=' -C instrument-coverage' uv run maturin develop --uv --release
59
54
60
- .PHONY : build-pgo
55
+ .PHONY : build-pgo # # Build the PGO version of the package
61
56
build-pgo :
62
57
@rm -f python/pydantic_core/* .so
63
58
$(eval PROFDATA := $(shell mktemp -d) )
@@ -69,44 +64,44 @@ build-pgo:
69
64
@rm -rf $(PROFDATA )
70
65
71
66
72
- .PHONY : build-wasm
67
+ .PHONY : build-wasm # # Build the WebAssembly version of the package
73
68
build-wasm :
74
69
@echo ' This requires python 3.12, maturin and emsdk to be installed'
75
70
uv run maturin build --release --target wasm32-unknown-emscripten --out dist -i 3.12
76
71
ls -lh dist
77
72
78
- .PHONY : format
73
+ .PHONY : format # # Auto-format rust and python source files
79
74
format :
80
75
uv run ruff check --fix $(sources )
81
76
uv run ruff format $(sources )
82
77
cargo fmt
83
78
84
- .PHONY : lint-python
79
+ .PHONY : lint-python # # Lint python source files
85
80
lint-python :
86
81
uv run ruff check $(sources )
87
82
uv run ruff format --check $(sources )
88
83
uv run griffe dump -f -d google -LWARNING -o/dev/null python/pydantic_core
89
84
$(mypy-stubtest )
90
85
91
- .PHONY : lint-rust
86
+ .PHONY : lint-rust # # Lint rust source files
92
87
lint-rust :
93
88
cargo fmt --version
94
89
cargo fmt --all -- --check
95
90
cargo clippy --version
96
91
cargo clippy --tests -- -D warnings
97
92
98
- .PHONY : lint
93
+ .PHONY : lint # # Lint rust and python source files
99
94
lint : lint-python lint-rust
100
95
101
- .PHONY : pyright
96
+ .PHONY : pyright # # Perform type-checking with pyright
102
97
pyright :
103
98
uv run pyright
104
99
105
- .PHONY : test
100
+ .PHONY : test # # Run all tests
106
101
test :
107
102
uv run pytest
108
103
109
- .PHONY : testcov
104
+ .PHONY : testcov # # Run tests and generate a coverage report
110
105
testcov : build-coverage
111
106
@rm -rf htmlcov
112
107
@mkdir -p htmlcov
@@ -115,10 +110,10 @@ testcov: build-coverage
115
110
coverage html -d htmlcov/python
116
111
coverage-prepare html python/pydantic_core/* .so
117
112
118
- .PHONY : all
113
+ .PHONY : all # # Run the standard set of checks performed in CI
119
114
all : format build-dev lint test
120
115
121
- .PHONY : clean
116
+ .PHONY : clean # # Clear local caches and build artifacts
122
117
clean :
123
118
rm -rf ` find . -name __pycache__`
124
119
rm -f ` find . -type f -name ' *.py[co]' `
@@ -133,3 +128,10 @@ clean:
133
128
rm -rf build
134
129
rm -rf perf.data*
135
130
rm -rf python/pydantic_core/* .so
131
+
132
+ .PHONY : help # # Display this message
133
+ help :
134
+ @grep -E \
135
+ ' ^.PHONY: .*?## .*$$' $(MAKEFILE_LIST ) | \
136
+ sort | \
137
+ awk ' BEGIN {FS = ".PHONY: |## "}; {printf "\033[36m%-19s\033[0m %s\n", $$2, $$3}'
0 commit comments