Skip to content

Commit 8908e26

Browse files
authored
Add uv python install --preview to the documentation (#10010)
1 parent 2b0f8ff commit 8908e26

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed

docs/concepts/python-versions.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,45 @@ latest version. If a `.python-version` file is present, uv will install the Pyth
110110
the file. A project that requires multiple Python versions may define a `.python-versions` file. If
111111
present, uv will install all of the Python versions listed in the file.
112112

113+
### Installing Python executables
114+
115+
!!! important
116+
117+
Support for installing Python executables is in _preview_, this means the behavior is experimental
118+
and subject to change.
119+
120+
To install Python executables into your `PATH`, provide the `--preview` option:
121+
122+
```console
123+
$ uv python install 3.12 --preview
124+
```
125+
126+
This will install a Python executable for the requested version into `~/.local/bin`, e.g., as
127+
`python3.12`.
128+
129+
!!! tip
130+
131+
If `~/.local/bin` is not in your `PATH`, you can add it with `uv tool update-shell`.
132+
133+
To install `python` and `python3` executables, include the `--default` option:
134+
135+
```console
136+
$ uv python install 3.12 --default --preview
137+
```
138+
139+
When installing Python executables, uv will only overwrite an existing executable if it is managed
140+
by uv — e.g., if `~/.local/bin/python3.12` exists already uv will not overwrite it without the
141+
`--force` flag.
142+
143+
uv will update executables that it manages. However, it will prefer the latest patch version of each
144+
Python minor version by default. For example:
145+
146+
```console
147+
$ uv python install 3.12.7 --preview # Adds `python3.12` to `~/.local/bin`
148+
$ uv python install 3.12.6 --preview # Does not update `python3.12`
149+
$ uv python install 3.12.8 --preview # Updates `python3.12` to point to 3.12.8
150+
```
151+
113152
## Project Python versions
114153

115154
uv will respect Python requirements defined in `requires-python` in the `pyproject.toml` file during

docs/guides/install-python.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,15 @@ system. If you've previously installed Python with uv, a new version will not be
2525

2626
Python does not publish official distributable binaries. As such, uv uses distributions from Astral [`python-build-standalone`](https://github.com/astral-sh/python-build-standalone) project. See the [Python distributions](../concepts/python-versions.md#managed-python-distributions) documentation for more details.
2727

28-
<!-- TODO(zanieb): Restore when Python shim management is added
29-
Note that when an automatic Python installation occurs, the `python` command will not be added to the shell. Use `uv python install-shim` to ensure the `python` shim is installed.
30-
31-
Once Python is installed, it can be invoked via `python`:
32-
33-
```console
34-
$ python --version
35-
```
36-
37-
To prevent uv from managing Python system-wide, provide the `--no-shim` option during installation.
38-
-->
39-
4028
Once Python is installed, it will be used by `uv` commands automatically.
4129

4230
!!! important
4331

4432
When Python is installed by uv, it will not be available globally (i.e. via the `python` command).
45-
Support for this feature is planned for a future release. In the meantime, use
33+
Support for this feature is in _preview_. See [Installing Python executables](../concepts/python-versions.md#installing-python-executables)
34+
for details.
35+
36+
You can still use
4637
[`uv run`](../guides/scripts.md#using-different-python-versions) or
4738
[create and activate a virtual environment](../pip/environments.md) to use `python` directly.
4839

0 commit comments

Comments
 (0)