mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-27 04:29:10 +00:00
Fix some outdated documentation discussing Python environments (#6058)
Starting on https://github.com/astral-sh/uv/issues/5966 noticed various problems
This commit is contained in:
parent
ef948619ee
commit
e8876ada6d
2 changed files with 12 additions and 29 deletions
|
@ -134,20 +134,6 @@ To exclude downloads and only show installed Python versions:
|
||||||
$ uv python list --only-installed
|
$ 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
|
## Discovery of Python versions
|
||||||
|
|
||||||
When searching for a Python version, the following locations are checked:
|
When searching for a Python version, the following locations are checked:
|
||||||
|
@ -158,6 +144,12 @@ When searching for a Python version, the following locations are checked:
|
||||||
- On Windows, the Python interpreter returned by `py --list-paths` that matches the requested
|
- On Windows, the Python interpreter returned by `py --list-paths` that matches the requested
|
||||||
version.
|
version.
|
||||||
|
|
||||||
|
In some cases, uv allows using a Python version from a virtual environment. In this case, the
|
||||||
|
virtual environment's interpreter will be checked for compatibility with the request before
|
||||||
|
searching for an installation as described above. See the
|
||||||
|
[pip-compatible virtual environment discovery](../pip/environments.md#discovery-of-python-environments)
|
||||||
|
documentation for details.
|
||||||
|
|
||||||
When performing discovery, non-executable files will be ignored. Each discovered executable is
|
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
|
queried for metadata to ensure it meets the [requested Python version](#requesting-a-version). If
|
||||||
the query fails, the executable will be skipped. If the executable satisfies the request, it is used
|
the query fails, the executable will be skipped. If the executable satisfies the request, it is used
|
||||||
|
|
|
@ -107,18 +107,9 @@ will search for a virtual environment in the following order:
|
||||||
If no virtual environment is found, uv will prompt the user to create one in the current directory
|
If no virtual environment is found, uv will prompt the user to create one in the current directory
|
||||||
via `uv venv`.
|
via `uv venv`.
|
||||||
|
|
||||||
If the `--system` flag is included, uv will skip virtual environments and search for:
|
If the `--system` flag is included, uv will skip virtual environments search for an installed Python
|
||||||
|
version. Similarly, when running a command that does not mutate the environment such as
|
||||||
- The Python interpreter available as `python3` on macOS and Linux, or `python.exe` on Windows.
|
`uv pip compile`, uv does not _require_ a virtual environment — however, a Python interpreter is
|
||||||
- On Windows, the Python interpreter returned by `py --list-paths` that matches the requested
|
still required. See the documentation on
|
||||||
version.
|
[Python discovery](../concepts/python-versions.md#discovery-order) for details on the discovery of
|
||||||
|
installed Python versions.
|
||||||
If a specific Python version is requested, e.g., `--python 3.7`, additional executable names are
|
|
||||||
included:
|
|
||||||
|
|
||||||
- The Python interpreter available as, e.g., `python3.7` on macOS and Linux.
|
|
||||||
|
|
||||||
When running a command that does not mutate the environment such as `uv pip compile`, uv does not
|
|
||||||
_require_ a virtual environment. Instead, it needs a Python toolchain to create ephemeral
|
|
||||||
environments. See the documentation on
|
|
||||||
[toolchain discovery](../concepts/python-versions.md#discovery-order) for details on discovery.
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue