diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e65b1f9a541..fa0ecdbc155f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,7 +135,7 @@ jobs: - name: "Install required Python versions" run: | - cargo run -p uv-dev -- fetch-python + cargo run toolchain install - name: "Install cargo nextest" uses: taiki-e/install-action@v2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 98a2a473f7f2..f7ab2827ee15 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,7 +39,7 @@ If tests fail due to a mismatch in the JSON Schema, run: `cargo dev generate-jso Testing uv requires multiple specific Python versions; they can be installed with: ```shell -cargo dev fetch-python +cargo run toolchain install ``` The storage directory can be configured with `UV_TOOLCHAIN_DIR`. diff --git a/Cargo.lock b/Cargo.lock index 735d3d91fc6d..4d552aed4fef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4640,7 +4640,6 @@ dependencies = [ "distribution-filename", "distribution-types", "fs-err", - "futures", "install-wheel-rs", "mimalloc", "owo-colors", @@ -4665,7 +4664,6 @@ dependencies = [ "uv-configuration", "uv-dispatch", "uv-distribution", - "uv-fs", "uv-git", "uv-installer", "uv-resolver", diff --git a/crates/uv-dev/Cargo.toml b/crates/uv-dev/Cargo.toml index 2720ee9c53b3..00cd34e05e91 100644 --- a/crates/uv-dev/Cargo.toml +++ b/crates/uv-dev/Cargo.toml @@ -27,7 +27,6 @@ uv-client = { workspace = true } uv-configuration = { workspace = true } uv-dispatch = { workspace = true } uv-distribution = { workspace = true, features = ["schemars"] } -uv-fs = { workspace = true } uv-git = { workspace = true } uv-installer = { workspace = true } uv-resolver = { workspace = true } @@ -41,7 +40,6 @@ anstream = { workspace = true } anyhow = { workspace = true } clap = { workspace = true, features = ["derive", "wrap_help"] } fs-err = { workspace = true, features = ["tokio"] } -futures = { workspace = true } owo-colors = { workspace = true } poloto = { version = "19.1.2", optional = true } pretty_assertions = { version = "1.4.0" } diff --git a/crates/uv-dev/src/fetch_python.rs b/crates/uv-dev/src/fetch_python.rs deleted file mode 100644 index 859ec800819d..000000000000 --- a/crates/uv-dev/src/fetch_python.rs +++ /dev/null @@ -1,104 +0,0 @@ -use anyhow::Result; -use clap::Parser; -use fs_err as fs; -use futures::StreamExt; -use tokio::time::Instant; -use tracing::{info, info_span, Instrument}; -use uv_toolchain::ToolchainRequest; - -use uv_fs::Simplified; -use uv_toolchain::downloads::{DownloadResult, Error, PythonDownload, PythonDownloadRequest}; -use uv_toolchain::managed::{InstalledToolchain, InstalledToolchains}; - -#[derive(Parser, Debug)] -pub(crate) struct FetchPythonArgs { - versions: Vec, -} - -pub(crate) async fn fetch_python(args: FetchPythonArgs) -> Result<()> { - let start = Instant::now(); - - let toolchains = InstalledToolchains::from_settings()?.init()?; - let toolchain_dir = toolchains.root(); - - let versions = if args.versions.is_empty() { - info!("Reading versions from file..."); - read_versions_file().await? - } else { - args.versions - }; - - let requests = versions - .iter() - .map(|version| { - PythonDownloadRequest::from_request(ToolchainRequest::parse(version)) - // Populate platform information on the request - .and_then(PythonDownloadRequest::fill) - }) - .collect::, Error>>()?; - - let downloads = requests - .iter() - .map(PythonDownload::from_request) - .collect::, Error>>()?; - - let client = uv_client::BaseClientBuilder::new().build(); - - info!("Fetching requested versions..."); - let mut tasks = futures::stream::iter(downloads.iter()) - .map(|download| { - async { - let result = download.fetch(&client, toolchain_dir).await; - (download.python_version(), result) - } - .instrument(info_span!("download", key = %download)) - }) - .buffered(4); - - let mut results = Vec::new(); - let mut downloaded = 0; - while let Some(task) = tasks.next().await { - let (version, result) = task; - let path = match result? { - DownloadResult::AlreadyAvailable(path) => { - info!("Found existing download for v{}", version); - path - } - DownloadResult::Fetched(path) => { - info!("Downloaded v{} to {}", version, path.user_display()); - downloaded += 1; - path - } - }; - results.push((version, path)); - } - - for (_, path) in results { - let installed = InstalledToolchain::new(path)?; - installed.ensure_externally_managed()?; - } - - if downloaded > 0 { - let s = if downloaded == 1 { "" } else { "s" }; - info!( - "Fetched {} in {}s", - format!("{} version{}", downloaded, s), - start.elapsed().as_secs() - ); - } else { - info!("All versions downloaded already."); - }; - - info!("Installed {} versions", requests.len()); - - Ok(()) -} - -async fn read_versions_file() -> Result> { - let lines: Vec = fs::tokio::read_to_string(".python-versions") - .await? - .lines() - .map(ToString::to_string) - .collect(); - Ok(lines) -} diff --git a/crates/uv-dev/src/main.rs b/crates/uv-dev/src/main.rs index 75b19dbc0116..4cf109bd0fe6 100644 --- a/crates/uv-dev/src/main.rs +++ b/crates/uv-dev/src/main.rs @@ -19,7 +19,6 @@ use tracing_subscriber::{EnvFilter, Layer}; use crate::build::{build, BuildArgs}; use crate::clear_compile::ClearCompileArgs; use crate::compile::CompileArgs; -use crate::fetch_python::FetchPythonArgs; use crate::generate_json_schema::GenerateJsonSchemaArgs; #[cfg(feature = "render")] use crate::render_benchmarks::RenderBenchmarksArgs; @@ -44,7 +43,6 @@ static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; mod build; mod clear_compile; mod compile; -mod fetch_python; mod generate_json_schema; mod render_benchmarks; mod wheel_metadata; @@ -61,8 +59,6 @@ enum Cli { Compile(CompileArgs), /// Remove all `.pyc` in the tree. ClearCompile(ClearCompileArgs), - /// Fetch Python versions for testing. - FetchPython(FetchPythonArgs), /// Generate JSON schema for the TOML configuration file. GenerateJSONSchema(GenerateJsonSchemaArgs), #[cfg(feature = "render")] @@ -81,7 +77,6 @@ async fn run() -> Result<()> { Cli::WheelMetadata(args) => wheel_metadata::wheel_metadata(args).await?, Cli::Compile(args) => compile::compile(args).await?, Cli::ClearCompile(args) => clear_compile::clear_compile(&args)?, - Cli::FetchPython(args) => fetch_python::fetch_python(args).await?, Cli::GenerateJSONSchema(args) => generate_json_schema::main(&args)?, #[cfg(feature = "render")] Cli::RenderBenchmarks(args) => render_benchmarks::render_benchmarks(&args)?,