Skip to content

Commit 32e5b0d

Browse files
committed
basic uv setup
1 parent cf3161c commit 32e5b0d

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.ipynb_checkpoints/
22
.vscode/
33
.venv3?/
4+
.venv/
45
*.sublime-project
56
*.sublime-workspace
67
.env*

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,52 @@
33
Example code for the book **Fluent Python, Second Edition** by Luciano Ramalho (O'Reilly, 2022).
44

55

6+
## Running the code with [uv](https://docs.astral.sh/uv/)
7+
8+
This repository ships with a `pyproject.toml` and `uv.lock` so a single shared environment covers the example code across chapters. Python 3.12 is pinned via `.python-version`.
9+
10+
### One-time setup
11+
12+
```sh
13+
uv sync
14+
```
15+
16+
That installs the runtime deps (`click`, `fastapi`, `geolib`, `httpx`, `tqdm`, `uvicorn`) plus the dev tools (`pytest`, `mypy`, `ruff`) into `.venv/`.
17+
18+
### Running scripts
19+
20+
Use `uv run` — no need to activate the venv:
21+
22+
```sh
23+
uv run python 19-concurrency/spinner_thread.py
24+
uv run python 20-executors/demo_executor_map.py
25+
```
26+
27+
### Running doctests
28+
29+
`pytest.ini` is configured with `--doctest-modules`, so most chapter files double as doctests:
30+
31+
```sh
32+
uv run pytest 11-pythonic-obj/vector2d_v0.py
33+
uv run pytest 17-it-generator/sentence.py
34+
```
35+
36+
### Type-checking and linting
37+
38+
```sh
39+
uv run mypy 11-pythonic-obj/vector2d_v0.py
40+
uv run ruff check 11-pythonic-obj/
41+
```
42+
43+
### Caveats
44+
45+
- **`curio`** (used only in [21-async/domains/curio](21-async/domains/curio)) is *not* in the shared env — its latest release is broken on Python 3.12. To run that example, create a separate environment with Python ≤3.11:
46+
```sh
47+
cd 21-async/domains/curio && uv venv --python 3.11 && uv pip install curio
48+
```
49+
- A few chapters have their own `requirements.txt` from the upstream book repo. They overlap with the root environment and can generally be ignored.
50+
51+
652
## Table of Contents
753

854
All chapters are undergoing review and updates, including significant rewrites in the chapters about concurrency in **Part V**.

0 commit comments

Comments
 (0)