@@ -15,49 +15,50 @@ USE_MATURIN = $(shell [ "$$VIRTUAL_ENV" != "" ] && (which maturin))
1515 @uv -V || echo ' Please install uv: https://docs.astral.sh/uv/getting-started/installation/'
1616
1717.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/ '
18+ .pre-commit : .uv
19+ @uv run pre-commit -V || uv pip install pre-commit
2020
21- .PHONY : install
21+ .PHONY : install # # Install the package, dependencies, and pre-commit for local development
2222install : .uv .pre-commit
2323 uv pip install -U wheel
2424 uv sync --frozen --group all
25- uv pip install -v -e .
26- pre-commit install
25+ uv pip install pre-commit
26+ uv run pre-commit install --install-hooks
2727
2828.PHONY : rebuild-lockfiles # # Rebuild lockfiles from scratch, updating all dependencies
2929rebuild-lockfiles : .uv
3030 uv lock --upgrade
3131
32- .PHONY : install-rust-coverage
32+ .PHONY : install-rust-coverage # # Install Rust coverage tools
3333install-rust-coverage :
3434 cargo install rustfilt coverage-prepare
3535 rustup component add llvm-tools-preview
3636
37- .PHONY : install-pgo
37+ .PHONY : install-pgo # # Install Rust PGO tools
38+ install-pgo :
3839 rustup component add llvm-tools-preview
3940
40- .PHONY : build-dev
41+ .PHONY : build-dev # # Build the development version of the package
4142build-dev :
4243 @rm -f python/pydantic_core/* .so
4344 uv run maturin develop --uv
4445
45- .PHONY : build-prod
46+ .PHONY : build-prod # # Build the production version of the package
4647build-prod :
4748 @rm -f python/pydantic_core/* .so
4849 uv run maturin develop --uv --release
4950
50- .PHONY : build-profiling
51+ .PHONY : build-profiling # # Build the profiling version of the package
5152build-profiling :
5253 @rm -f python/pydantic_core/* .so
5354 uv run maturin develop --uv --profile profiling
5455
55- .PHONY : build-coverage
56+ .PHONY : build-coverage # # Build the coverage version of the package
5657build-coverage :
5758 @rm -f python/pydantic_core/* .so
5859 RUSTFLAGS=' -C instrument-coverage' uv run maturin develop --uv --release
5960
60- .PHONY : build-pgo
61+ .PHONY : build-pgo # # Build the PGO version of the package
6162build-pgo :
6263 @rm -f python/pydantic_core/* .so
6364 $(eval PROFDATA := $(shell mktemp -d) )
@@ -69,44 +70,44 @@ build-pgo:
6970 @rm -rf $(PROFDATA )
7071
7172
72- .PHONY : build-wasm
73+ .PHONY : build-wasm # # Build the WebAssembly version of the package
7374build-wasm :
7475 @echo ' This requires python 3.12, maturin and emsdk to be installed'
7576 uv run maturin build --release --target wasm32-unknown-emscripten --out dist -i 3.12
7677 ls -lh dist
7778
78- .PHONY : format
79+ .PHONY : format # # Auto-format rust and python source files
7980format :
8081 uv run ruff check --fix $(sources )
8182 uv run ruff format $(sources )
8283 cargo fmt
8384
84- .PHONY : lint-python
85+ .PHONY : lint-python # # Lint python source files
8586lint-python :
8687 uv run ruff check $(sources )
8788 uv run ruff format --check $(sources )
8889 uv run griffe dump -f -d google -LWARNING -o/dev/null python/pydantic_core
8990 $(mypy-stubtest )
9091
91- .PHONY : lint-rust
92+ .PHONY : lint-rust # # Lint rust source files
9293lint-rust :
9394 cargo fmt --version
9495 cargo fmt --all -- --check
9596 cargo clippy --version
9697 cargo clippy --tests -- -D warnings
9798
98- .PHONY : lint
99+ .PHONY : lint # # Lint rust and python source files
99100lint : lint-python lint-rust
100101
101- .PHONY : pyright
102+ .PHONY : pyright # # Perform type-checking with pyright
102103pyright :
103104 uv run pyright
104105
105- .PHONY : test
106+ .PHONY : test # # Run all tests
106107test :
107108 uv run pytest
108109
109- .PHONY : testcov
110+ .PHONY : testcov # # Run tests and generate a coverage report
110111testcov : build-coverage
111112 @rm -rf htmlcov
112113 @mkdir -p htmlcov
@@ -115,10 +116,10 @@ testcov: build-coverage
115116 coverage html -d htmlcov/python
116117 coverage-prepare html python/pydantic_core/* .so
117118
118- .PHONY : all
119+ .PHONY : all # # Run the standard set of checks performed in CI
119120all : format build-dev lint test
120121
121- .PHONY : clean
122+ .PHONY : clean # # Clear local caches and build artifacts
122123clean :
123124 rm -rf ` find . -name __pycache__`
124125 rm -f ` find . -type f -name ' *.py[co]' `
@@ -133,3 +134,10 @@ clean:
133134 rm -rf build
134135 rm -rf perf.data*
135136 rm -rf python/pydantic_core/* .so
137+
138+ .PHONY : help # # Display this message
139+ help :
140+ @grep -E \
141+ ' ^.PHONY: .*?## .*$$' $(MAKEFILE_LIST ) | \
142+ sort | \
143+ awk ' BEGIN {FS = ".PHONY: |## "}; {printf "\033[36m%-19s\033[0m %s\n", $$2, $$3}'
0 commit comments