Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions crates/uv/src/commands/tool/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand Down
16 changes: 7 additions & 9 deletions crates/uv/src/commands/tool/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
Loading