Add --install-dir arg to uv python install and uninstall (#7920)

## Summary

This PR adds `--install-dir` argument for the following commands:
- `uv python install`
- `uv python uninstall`

The `UV_PYTHON_INSTALL_DIR` env variable can be used to set it
(previously it was also used internally).

Any more commands we would want to add this to? 

## Test Plan

For now just manual test (works on my machine hehe)

```
❯ ./target/debug/uv python install --install-dir /tmp/pythons 3.8.12
Searching for Python versions matching: Python 3.8.12
Installed Python 3.8.12 in 4.31s
 + cpython-3.8.12-linux-x86_64-gnu
❯ /tmp/pythons/cpython-3.8.12-linux-x86_64-gnu/bin/python --help
usage: /tmp/pythons/cpython-3.8.12-linux-x86_64-gnu/bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ...
```

Open to add some tests after the initial feedback.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
Daniel Gafni 2024-12-10 19:04:31 +02:00 committed by GitHub
parent b751648bfe
commit d0ccc9a16f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 76 additions and 19 deletions

View file

@ -302,7 +302,7 @@ fn python_executables_from_installed<'a>(
preference: PythonPreference,
) -> Box<dyn Iterator<Item = Result<(PythonSource, PathBuf), Error>> + 'a> {
let from_managed_installations = std::iter::once_with(move || {
ManagedPythonInstallations::from_settings()
ManagedPythonInstallations::from_settings(None)
.map_err(Error::from)
.and_then(|installed_installations| {
debug!(