Skip to content

Commit f392d4e

Browse files
committed
docs: add uv feature documentation
1 parent ead7fa2 commit f392d4e

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

docs/features/uv.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# uv
2+
3+
An ultra-fast Python project manager that simplifies working with dependencies and tools without unnecessary steps.
4+
5+
---
6+
7+
## What is it used for here?
8+
!!! question "!"
9+
- **Installs all current project dependencies and features** (main and dev) after cloning (project initialization)
10+
- **Automatically creates an isolated environment** (similar to venv, but without manual steps)
11+
- **Allows running any Python tools** (e.g., pytest, ruff, mypy) without activating venv or extra configuration
12+
- **Ensures a consistent environment for local development, CI/CD, and devcontainer**
13+
14+
---
15+
16+
## How it works in this template
17+
18+
- After cloning the project, just run:
19+
```bash
20+
make init
21+
```
22+
This command:
23+
- Installs all dependencies via uv
24+
- Sets up pre-commit hooks
25+
26+
- To run Python tools (tests, linters, etc.), you needn't activate venv:
27+
```bash
28+
uv run pytest
29+
uv run ruff check ./src/
30+
uv run mypy ./src/
31+
```
32+
33+
- To add a new dependency:
34+
```bash
35+
uv add <package-name>
36+
```
37+
or for dev dependencies:
38+
```bash
39+
uv add --group dev <package-name>
40+
```
41+
42+
---
43+
44+
## How to update or change the Python version for the project
45+
46+
!!! tip "!"
47+
48+
1. **Edit** the Python version in [pyproject.toml](https://github.com/python-boilerplate/uv-template/blob/main/pyproject.toml), for example:
49+
50+
```toml title="pyproject.toml"
51+
[project]
52+
requires-python = ">=3.11"
53+
```
54+
55+
2. **Remove the old environment (optional):**
56+
57+
```bash
58+
rm -r .venv
59+
```
60+
61+
3. **Change the Python version in your `.python-version` file:**
62+
63+
```bash
64+
uv python pin 3.11
65+
```
66+
67+
- You can specify any interpreter available on your system (`python3.12`, `python3.10`, etc.).
68+
- If the specified Python version is not installed, uv will automatically install it.
69+
- If you don't specify a version, uv uses the current Python version installed on your system.
70+
71+
4. **Reinstall dependencies:**
72+
73+
```bash
74+
make init
75+
76+
# or only dependencies without reinstalling hooks
77+
uv sync --link-mode=copy
78+
```
79+
80+
- The project now uses the desired Python version in its venv.
81+
82+
---
83+
84+
85+
## Configuration
86+
87+
- All configuration for uv in this template is located in [pyproject.toml](https://github.com/python-boilerplate/uv-template/blob/main/pyproject.toml) (file is generated automatically by uv).
88+
89+
---
90+
91+
For more details on configuration, see the [uv Documentation](https://github.com/astral-sh/uv)

0 commit comments

Comments
 (0)