mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Document virtual environment discovery (#5965)
This commit is contained in:
parent
4df0fe9a01
commit
44f94524f3
1 changed files with 19 additions and 1 deletions
|
@ -134,6 +134,20 @@ To exclude downloads and only show installed Python versions:
|
|||
$ uv python list --only-installed
|
||||
```
|
||||
|
||||
## Discovery of virtual environments
|
||||
|
||||
Some uv commands may use a Python interpreter from a virtual environment. When searching for virtual
|
||||
environments, uv prioritizes (in order):
|
||||
|
||||
- The `VIRTUAL_ENV` environment variable.
|
||||
- The `CONDA_PREFIX` environment variable.
|
||||
- A `.venv` directory in the working directory.
|
||||
- A `.venv` directory in any parent directory.
|
||||
|
||||
After exhausting these possibilities, uv will either
|
||||
[search for a Python installation](#discovery-of-python-versions) or exit with an error if the
|
||||
command requires a virtual environment.
|
||||
|
||||
## Discovery of Python versions
|
||||
|
||||
When searching for a Python version, the following locations are checked:
|
||||
|
@ -146,7 +160,11 @@ When searching for a Python version, the following locations are checked:
|
|||
|
||||
When performing discovery, non-executable files will be ignored. Each discovered executable is
|
||||
queried for metadata to ensure it meets the [requested Python version](#requesting-a-version). If
|
||||
the query fails, the executable will be skipped.
|
||||
the query fails, the executable will be skipped. If the executable satisfies the request, it is used
|
||||
without inspecting additional executables.
|
||||
|
||||
When searching for a managed Python version, uv will prefer newer versions first. When searching for
|
||||
a system Python version, uv will use the first compatible version — not the newest version.
|
||||
|
||||
If a Python version cannot be found on the system, uv will check for a compatible managed Python
|
||||
version download.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue