Remove cargo dev fetch-python (#4337)

This has been fully replaced by `uv toolchain install`
This commit is contained in:
Zanie Blue 2024-06-17 14:49:06 -04:00 committed by GitHub
parent 05d79f8d38
commit 631994c485
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 2 additions and 115 deletions

View file

@ -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

View file

@ -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`.

2
Cargo.lock generated
View file

@ -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",

View file

@ -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" }

View file

@ -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<String>,
}
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::<Result<Vec<_>, Error>>()?;
let downloads = requests
.iter()
.map(PythonDownload::from_request)
.collect::<Result<Vec<_>, 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<Vec<String>> {
let lines: Vec<String> = fs::tokio::read_to_string(".python-versions")
.await?
.lines()
.map(ToString::to_string)
.collect();
Ok(lines)
}

View file

@ -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)?,