Skip to content

Commit 23cdc37

Browse files
committed
docs: improve onboarding
Onboarding was not up to date now that `uv` is really supported everywhere. - `make install` now only relies on `uv` - `make help` is a new target to describe all targets with their meaning - README setup section is way clearer
1 parent 1b3815c commit 23cdc37

File tree

2 files changed

+67
-42
lines changed

2 files changed

+67
-42
lines changed

Makefile

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,49 +15,49 @@ 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
2222
install: .uv .pre-commit
23-
uv pip install -U wheel
2423
uv sync --frozen --group all
25-
uv pip install -v -e .
26-
pre-commit install
24+
uv pip install pre-commit
25+
uv run pre-commit install --install-hooks
2726

2827
.PHONY: rebuild-lockfiles ## Rebuild lockfiles from scratch, updating all dependencies
2928
rebuild-lockfiles: .uv
3029
uv lock --upgrade
3130

32-
.PHONY: install-rust-coverage
31+
.PHONY: install-rust-coverage ## Install Rust coverage tools
3332
install-rust-coverage:
3433
cargo install rustfilt coverage-prepare
3534
rustup component add llvm-tools-preview
3635

37-
.PHONY: install-pgo
36+
.PHONY: install-pgo ## Install Rust PGO tools
37+
install-pgo:
3838
rustup component add llvm-tools-preview
3939

40-
.PHONY: build-dev
40+
.PHONY: build-dev ## Build the development version of the package
4141
build-dev:
4242
@rm -f python/pydantic_core/*.so
4343
uv run maturin develop --uv
4444

45-
.PHONY: build-prod
45+
.PHONY: build-prod ## Build the production version of the package
4646
build-prod:
4747
@rm -f python/pydantic_core/*.so
4848
uv run maturin develop --uv --release
4949

50-
.PHONY: build-profiling
50+
.PHONY: build-profiling ## Build the profiling version of the package
5151
build-profiling:
5252
@rm -f python/pydantic_core/*.so
5353
uv run maturin develop --uv --profile profiling
5454

55-
.PHONY: build-coverage
55+
.PHONY: build-coverage ## Build the coverage version of the package
5656
build-coverage:
5757
@rm -f python/pydantic_core/*.so
5858
RUSTFLAGS='-C instrument-coverage' uv run maturin develop --uv --release
5959

60-
.PHONY: build-pgo
60+
.PHONY: build-pgo ## Build the PGO version of the package
6161
build-pgo:
6262
@rm -f python/pydantic_core/*.so
6363
$(eval PROFDATA := $(shell mktemp -d))
@@ -69,44 +69,44 @@ build-pgo:
6969
@rm -rf $(PROFDATA)
7070

7171

72-
.PHONY: build-wasm
72+
.PHONY: build-wasm ## Build the WebAssembly version of the package
7373
build-wasm:
7474
@echo 'This requires python 3.12, maturin and emsdk to be installed'
7575
uv run maturin build --release --target wasm32-unknown-emscripten --out dist -i 3.12
7676
ls -lh dist
7777

78-
.PHONY: format
78+
.PHONY: format ## Auto-format rust and python source files
7979
format:
8080
uv run ruff check --fix $(sources)
8181
uv run ruff format $(sources)
8282
cargo fmt
8383

84-
.PHONY: lint-python
84+
.PHONY: lint-python ## Lint python source files
8585
lint-python:
8686
uv run ruff check $(sources)
8787
uv run ruff format --check $(sources)
8888
uv run griffe dump -f -d google -LWARNING -o/dev/null python/pydantic_core
8989
$(mypy-stubtest)
9090

91-
.PHONY: lint-rust
91+
.PHONY: lint-rust ## Lint rust source files
9292
lint-rust:
9393
cargo fmt --version
9494
cargo fmt --all -- --check
9595
cargo clippy --version
9696
cargo clippy --tests -- -D warnings
9797

98-
.PHONY: lint
98+
.PHONY: lint ## Lint rust and python source files
9999
lint: lint-python lint-rust
100100

101-
.PHONY: pyright
101+
.PHONY: pyright ## Perform type-checking with pyright
102102
pyright:
103103
uv run pyright
104104

105-
.PHONY: test
105+
.PHONY: test ## Run all tests
106106
test:
107107
uv run pytest
108108

109-
.PHONY: testcov
109+
.PHONY: testcov ## Run tests and generate a coverage report
110110
testcov: build-coverage
111111
@rm -rf htmlcov
112112
@mkdir -p htmlcov
@@ -115,10 +115,10 @@ testcov: build-coverage
115115
coverage html -d htmlcov/python
116116
coverage-prepare html python/pydantic_core/*.so
117117

118-
.PHONY: all
118+
.PHONY: all ## Run the standard set of checks performed in CI
119119
all: format build-dev lint test
120120

121-
.PHONY: clean
121+
.PHONY: clean ## Clear local caches and build artifacts
122122
clean:
123123
rm -rf `find . -name __pycache__`
124124
rm -f `find . -type f -name '*.py[co]' `
@@ -133,3 +133,10 @@ clean:
133133
rm -rf build
134134
rm -rf perf.data*
135135
rm -rf python/pydantic_core/*.so
136+
137+
.PHONY: help ## Display this message
138+
help:
139+
@grep -E \
140+
'^.PHONY: .*?## .*$$' $(MAKEFILE_LIST) | \
141+
sort | \
142+
awk 'BEGIN {FS = ".PHONY: |## "}; {printf "\033[36m%-19s\033[0m %s\n", $$2, $$3}'

README.md

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,35 +69,53 @@ except ValidationError as e:
6969

7070
## Getting Started
7171

72-
You'll need rust stable [installed](https://rustup.rs/), or rust nightly if you want to generate accurate coverage.
72+
### Prerequisites
7373

74-
With rust and python 3.9+ installed, compiling pydantic-core should be possible with roughly the following:
74+
You'll need:
75+
1. **[Rust](https://rustup.rs/)** - Rust stable (or nightly for coverage)
76+
2. **[Python 3.9+](https://www.python.org/downloads/)** - Python 3.9 or later
77+
3. **[uv](https://docs.astral.sh/uv/getting-started/installation/)** - Fast Python package manager
78+
4. **[git](https://git-scm.com/)** - For version control
79+
5. **[make](https://www.gnu.org/software/make/)** - For running development commands (or use `nmake` on Windows)
80+
81+
### Quick Start
7582

7683
```bash
77-
# clone this repo or your fork
84+
# Clone the repository (or from your fork)
7885
git clone [email protected]:pydantic/pydantic-core.git
7986
cd pydantic-core
80-
# create a new virtual env
81-
python3 -m venv env
82-
source env/bin/activate
83-
# install dependencies and install pydantic-core
87+
88+
# Install all dependencies using uv, setup pre-commit hooks, and build the development version
8489
make install
8590
```
8691

87-
That should be it, the example shown above should now run.
92+
Verify your installation by running:
93+
94+
```bash
95+
make
96+
```
97+
98+
This runs a full development cycle: formatting, building, linting, and testing
99+
100+
### Development Commands
101+
102+
Run `make help` to see all available commands, or use these common ones:
103+
104+
```bash
105+
make build-dev # to build the package during development
106+
make build-prod # to perform an optimised build for benchmarking
107+
make test # to run the tests
108+
make testcov # to run the tests and generate a coverage report
109+
make lint # to run the linter
110+
make format # to format python and rust code
111+
make all # to run to run build-dev + format + lint + test
112+
```
88113

89-
You might find it useful to look at [`python/pydantic_core/_pydantic_core.pyi`](./python/pydantic_core/_pydantic_core.pyi) and
90-
[`python/pydantic_core/core_schema.py`](./python/pydantic_core/core_schema.py) for more information on the python API,
91-
beyond that, [`tests/`](./tests) provide a large number of examples of usage.
114+
### Useful Resources
92115

93-
If you want to contribute to pydantic-core, you'll want to use some other make commands:
94-
* `make build-dev` to build the package during development
95-
* `make build-prod` to perform an optimised build for benchmarking
96-
* `make test` to run the tests
97-
* `make testcov` to run the tests and generate a coverage report
98-
* `make lint` to run the linter
99-
* `make format` to format python and rust code
100-
* `make` to run `format build-dev lint test`
116+
* [`python/pydantic_core/_pydantic_core.pyi`](./python/pydantic_core/_pydantic_core.pyi) - Python API types
117+
* [`python/pydantic_core/core_schema.py`](./python/pydantic_core/core_schema.py) - Core schema definitions
118+
* [`tests/`](./tests) - Comprehensive usage examples
101119

102120
## Profiling
103121

0 commit comments

Comments
 (0)