Skip to content

Commit 6e13c2e

Browse files
authored
Create uv.md
1 parent d484403 commit 6e13c2e

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

python/uv.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Working with uv
2+
3+
`uv` is a Python package and project manager. It is extremely fast, compared with alternatives.
4+
5+
6+
## Installing
7+
8+
On Windows, you can install `uv` using Powershell:
9+
10+
```
11+
$ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
12+
```
13+
14+
More info on other installation options can be found on the [uv docs](https://docs.astral.sh/uv/getting-started/installation/).
15+
16+
To update uv:
17+
18+
```
19+
$ uv self update
20+
```
21+
22+
23+
## Starting a new project
24+
25+
Starting a project with `uv`:
26+
27+
```
28+
$ uv init project_name
29+
```
30+
31+
`uv` creates a new directory called `project_name` and sets up a few project files. You can then enter the project folder.
32+
33+
```
34+
$ cd project_name
35+
```
36+
37+
Note: If you already have a project folder you can ask `uv` to initialize the project there:
38+
39+
```
40+
$ cd project_name
41+
$ uv init
42+
```
43+
44+
When starting a new project you can specify the Python version using:
45+
46+
```
47+
$ uv init project_name --python 3.11
48+
```
49+
50+
## Installing packages
51+
52+
To add packages:
53+
54+
```
55+
$ cd project_name
56+
$ uv add requests flask
57+
```
58+
59+
Working with development dependencies:
60+
61+
```
62+
$ uv add --dev black
63+
$ uv run black path\to\file.py
64+
```
65+
66+
## Deploying
67+
68+
Deploying the project to production excluding dev dependencies:
69+
70+
```
71+
$ uv sync --no-dev
72+
```
73+
74+
## References
75+
76+
- [uv Documentation](https://docs.astral.sh/uv/)

0 commit comments

Comments
 (0)