Fetch managed toolchains if necessary in uv tool install and uv tool run (#4717)

Hey we should download toolchains here if we need to, right!?
This commit is contained in:
Zanie Blue 2024-07-01 22:27:43 -04:00 committed by GitHub
parent c0a06a2c1b
commit ad5151cda8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 18 deletions

View file

@ -10,7 +10,7 @@ use tracing::debug;
use distribution_types::Name;
use pypi_types::Requirement;
use uv_cache::Cache;
use uv_client::Connectivity;
use uv_client::{BaseClientBuilder, Connectivity};
use uv_configuration::{Concurrency, PreviewMode, Reinstall};
#[cfg(unix)]
use uv_fs::replace_symlink;
@ -40,7 +40,7 @@ pub(crate) async fn install(
settings: ResolverInstallerSettings,
preview: PreviewMode,
toolchain_preference: ToolchainPreference,
_toolchain_fetch: ToolchainFetch,
toolchain_fetch: ToolchainFetch,
connectivity: Connectivity,
concurrency: Concurrency,
native_tls: bool,
@ -51,16 +51,19 @@ pub(crate) async fn install(
warn_user_once!("`uv tool install` is experimental and may change without warning.");
}
// TODO(zanieb): Use `find_or_fetch` here
let interpreter = Toolchain::find(
&python
.as_deref()
.map(ToolchainRequest::parse)
.unwrap_or_default(),
let client_builder = BaseClientBuilder::new()
.connectivity(connectivity)
.native_tls(native_tls);
let interpreter = Toolchain::find_or_fetch(
python.as_deref().map(ToolchainRequest::parse),
EnvironmentPreference::OnlySystem,
toolchain_preference,
toolchain_fetch,
&client_builder,
cache,
)?
)
.await?
.into_interpreter();
// Initialize any shared state.

View file

@ -36,7 +36,7 @@ pub(crate) async fn run(
_isolated: bool,
preview: PreviewMode,
toolchain_preference: ToolchainPreference,
_toolchain_fetch: ToolchainFetch,
toolchain_fetch: ToolchainFetch,
connectivity: Connectivity,
concurrency: Concurrency,
native_tls: bool,
@ -77,17 +77,15 @@ pub(crate) async fn run(
debug!("Syncing ephemeral environment.");
// Discover an interpreter.
// Note we force preview on during `uv tool run` for now since the entire interface is in preview
// TODO(zanieb): We should use `find_or_fetch` here
let interpreter = Toolchain::find(
&python
.as_deref()
.map(ToolchainRequest::parse)
.unwrap_or_default(),
let interpreter = Toolchain::find_or_fetch(
python.as_deref().map(ToolchainRequest::parse),
EnvironmentPreference::OnlySystem,
toolchain_preference,
toolchain_fetch,
&client_builder,
cache,
)?
)
.await?
.into_interpreter();
// Create a virtual environment.