Install versioned Python executables into the bin directory during uv python install (#8458)

Updates `uv python install` to link `python3.x` in the executable
directory (i.e., `~/.local/bin`) to the the managed interpreter path.

Includes

- #8569 
- #8571 

Remaining work

- #8663 
- #8650 
- Add an opt-out setting and flag
- Update documentation
This commit is contained in:
Zanie Blue
2024-10-30 09:13:20 -05:00
committed by GitHub
parent 94fc35edd9
commit 4dd36b799f
19 changed files with 597 additions and 89 deletions
+24 -4
View File
@@ -4302,11 +4302,11 @@ Download and install Python versions.
Multiple Python versions may be requested.
Supports CPython and PyPy.
Supports CPython and PyPy. CPython distributions are downloaded from the `python-build-standalone` project. PyPy distributions are downloaded from `python.org`.
CPython distributions are downloaded from the `python-build-standalone` project.
Python versions are installed into the uv Python directory, which can be retrieved with `uv python dir`.
Python versions are installed into the uv Python directory, which can be retrieved with `uv python dir`. A `python` executable is not made globally available, managed Python versions are only used in uv commands or in active virtual environments.
A `python` executable is not made globally available, managed Python versions are only used in uv commands or in active virtual environments. There is experimental support for adding Python executables to the `PATH` — use the `--preview` flag to enable this behavior.
See `uv help python` to view supported request formats.
@@ -4693,6 +4693,8 @@ By default, Python installations are stored in the uv data directory at `$XDG_DA
The Python installation directory may be overridden with `$UV_PYTHON_INSTALL_DIR`.
To instead view the directory uv installs Python executables into, use the `--bin` flag.
<h3 class="cli-reference">Usage</h3>
```
@@ -4701,7 +4703,25 @@ uv python dir [OPTIONS]
<h3 class="cli-reference">Options</h3>
<dl class="cli-reference"><dt><code>--cache-dir</code> <i>cache-dir</i></dt><dd><p>Path to the cache directory.</p>
<dl class="cli-reference"><dt><code>--bin</code></dt><dd><p>Show the directory into which <code>uv python</code> will install Python executables.</p>
<p>Note this directory is only used when installing with preview mode enabled.</p>
<p>By default, <code>uv python dir</code> shows the directory into which the Python distributions themselves are installed, rather than the directory containing the linked executables.</p>
<p>The Python executable directory is determined according to the XDG standard and is derived from the following environment variables, in order of preference:</p>
<ul>
<li><code>$UV_PYTHON_BIN_DIR</code></li>
<li><code>$XDG_BIN_HOME</code></li>
<li><code>$XDG_DATA_HOME/../bin</code></li>
<li><code>$HOME/.local/bin</code></li>
</ul>
</dd><dt><code>--cache-dir</code> <i>cache-dir</i></dt><dd><p>Path to the cache directory.</p>
<p>Defaults to <code>$XDG_CACHE_HOME/uv</code> or <code>$HOME/.cache/uv</code> on macOS and Linux, and <code>%LOCALAPPDATA%\uv\cache</code> on Windows.</p>