Skip to content

Commit d6f1fc9

Browse files
authored
install improvements (#67)
1 parent deb48c7 commit d6f1fc9

File tree

6 files changed

+31
-37
lines changed

6 files changed

+31
-37
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ install: .uv .pre-commit
1313
uv sync --frozen --all-extras --group lint --group docs
1414
pre-commit install --install-hooks
1515

16+
.PHONY: sync # Update local packages and uv.lock
17+
sync: .uv
18+
uv sync --all-extras --group lint --group docs
19+
1620
.PHONY: format # Format the code
1721
format:
1822
uv run ruff format

docs/.hooks/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,25 @@ def on_page_markdown(markdown: str, page: Page, config: Config, files: Files) ->
1616

1717

1818
def replace_uv_python_run(markdown: str) -> str:
19-
return re.sub(r'```bash\n(.*?)python/uv[\- ]run(.+?)\n```', sub_run, markdown)
19+
return re.sub(r'```bash\n(.*?)(python/uv[\- ]run|pip/uv[\- ]add)(.+?)\n```', sub_run, markdown)
2020

2121

2222
def sub_run(m: re.Match[str]) -> str:
2323
prefix = m.group(1)
2424
command = m.group(2)
25+
install = 'pip' in command
26+
suffix = m.group(3)
2527
return f"""\
2628
=== "pip"
2729
2830
```bash
29-
{prefix}python{command}
31+
{prefix}{'pip install' if install else 'python'}{suffix}
3032
```
3133
3234
=== "uv"
3335
3436
```bash
35-
{prefix}uv run{command}
37+
{prefix}uv {'add' if install else 'run'}{suffix}
3638
```"""
3739

3840

docs/examples/index.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,9 @@ Either way you'll need to install extra dependencies to run some examples, you j
1212

1313
If you've installed `pydantic-ai` via pip/uv, you can install the extra dependencies with:
1414

15-
=== "pip"
16-
17-
```bash
18-
pip install 'pydantic-ai[examples]'
19-
```
20-
21-
=== "uv"
22-
23-
```bash
24-
uv add 'pydantic-ai[examples]'
25-
```
15+
```bash
16+
pip/uv-add 'pydantic-ai[examples]'
17+
```
2618

2719
If you clone the repo, you should instead use `uv sync --extra examples` to install extra dependencies.
2820

docs/install.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,36 @@
22

33
PydanticAI is available [on PyPI](https://pypi.org/project/pydantic-ai/) so installation is as simple as:
44

5-
=== "pip"
65

7-
```bash
8-
pip install pydantic-ai
9-
```
10-
11-
=== "uv"
12-
13-
```bash
14-
uv add pydantic-ai
15-
```
6+
```bash
7+
pip/uv-add pydantic-ai
8+
```
169

1710
It requires Python 3.9+.
1811

12+
!!! note "Use `--prerelease=allow` with uv"
13+
Until Pydantic v2.10 is released (very soon), you'll need to use `--prerelease=allow` with `uv` to install PydanticAI.
14+
1915
## Use with Pydantic Logfire
2016

2117
PydanticAI has an excellent (but completely optional) integration with [Pydantic Logfire](https://pydantic.dev/logfire) to help you view and understand agent runs.
2218

2319
To use Logfire with PydanticAI, install PydanticAI with the `logfire` optional group:
2420

25-
=== "pip"
21+
```bash
22+
pip/uv-add 'pydantic-ai[logfire]'
23+
```
2624

27-
```bash
28-
pip install 'pydantic-ai[logfire]'
29-
```
25+
From there, follow the [Logfire setup cods](logfire.md#integrating-logfire) to configure Logfire.
3026

31-
=== "uv"
27+
## Running Examples
3228

33-
```bash
34-
uv add 'pydantic-ai[logfire]'
35-
```
29+
PydanticAI bundles its examples so you can run them very easily.
3630

37-
From there, follow the [Logfire setup cods](logfire.md#integrating-logfire) to configure Logfire.
31+
To install extra dependencies required to run examples, install the `examples` optional group:
3832

39-
## Next Steps
33+
```bash
34+
pip/uv-add 'pydantic-ai[examples]'
35+
```
4036

41-
To run PydanticAI, follow instructions [in examples](examples/index.md).
37+
For next steps, follow instructions [in examples](examples/index.md).

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ dependencies = [
4444

4545
[project.optional-dependencies]
4646
logfire = [
47-
"logfire>=2",
47+
"logfire>=2.3",
4848
]
4949
examples = [
5050
"asyncpg>=0.30.0",

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)