From 913fc91afe0cb76057d807aedc9cb6c7006056c3 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 15 May 2024 12:02:44 -0400 Subject: [PATCH] Remove binary from `uv-virtualenv` crate (#3605) ## Summary I'm doing some refactoring and it requires updating this binary, but I doubt we really use it? --- Cargo.lock | 5 --- crates/uv-virtualenv/Cargo.toml | 12 ----- crates/uv-virtualenv/src/main.rs | 75 -------------------------------- 3 files changed, 92 deletions(-) delete mode 100644 crates/uv-virtualenv/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index c5e026348..d1fcb1700 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5071,9 +5071,6 @@ version = "0.1.44" name = "uv-virtualenv" version = "0.0.4" dependencies = [ - "anstream", - "clap", - "directories", "fs-err", "itertools 0.12.1", "pathdiff", @@ -5081,8 +5078,6 @@ dependencies = [ "pypi-types", "thiserror", "tracing", - "tracing-subscriber", - "uv-cache", "uv-fs", "uv-interpreter", "uv-version", diff --git a/crates/uv-virtualenv/Cargo.toml b/crates/uv-virtualenv/Cargo.toml index bd3be567e..515afd97b 100644 --- a/crates/uv-virtualenv/Cargo.toml +++ b/crates/uv-virtualenv/Cargo.toml @@ -13,30 +13,18 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } -[[bin]] -name = "uv-virtualenv" -required-features = ["cli"] - [lints] workspace = true [dependencies] platform-tags = { workspace = true } pypi-types = { workspace = true } -uv-cache = { workspace = true } uv-fs = { workspace = true } uv-interpreter = { workspace = true } uv-version = { workspace = true } -anstream = { workspace = true } -clap = { workspace = true, features = ["derive"], optional = true } -directories = { workspace = true } fs-err = { workspace = true } itertools = { workspace = true } pathdiff = { workspace = true } thiserror = { workspace = true } tracing = { workspace = true } -tracing-subscriber = { workspace = true, optional = true } - -[features] -cli = ["clap", "tracing-subscriber"] diff --git a/crates/uv-virtualenv/src/main.rs b/crates/uv-virtualenv/src/main.rs deleted file mode 100644 index a7f56b72f..000000000 --- a/crates/uv-virtualenv/src/main.rs +++ /dev/null @@ -1,75 +0,0 @@ -use std::error::Error; -use std::path::PathBuf; -use std::process::ExitCode; -use std::time::Instant; - -use anstream::eprintln; -use clap::Parser; -use directories::ProjectDirs; -use tracing::info; -use tracing_subscriber::layer::SubscriberExt; -use tracing_subscriber::util::SubscriberInitExt; -use tracing_subscriber::{fmt, EnvFilter}; - -use uv_cache::Cache; -use uv_interpreter::{find_default_python, find_requested_python}; -use uv_virtualenv::{create_bare_venv, Prompt}; - -#[derive(Parser, Debug)] -struct Cli { - path: Option, - #[clap(short, long)] - python: Option, - #[clap(long)] - prompt: Option, - #[clap(long)] - system_site_packages: bool, -} - -fn run() -> Result<(), uv_virtualenv::Error> { - let cli = Cli::parse(); - let location = cli.path.unwrap_or(PathBuf::from(".venv")); - let cache = if let Some(project_dirs) = ProjectDirs::from("", "", "uv-virtualenv") { - Cache::from_path(project_dirs.cache_dir())? - } else { - Cache::from_path(".cache")? - }; - let interpreter = if let Some(python_request) = &cli.python { - find_requested_python(python_request, &cache)?.ok_or( - uv_interpreter::Error::NoSuchPython(python_request.to_string()), - )? - } else { - find_default_python(&cache)? - }; - create_bare_venv( - &location, - &interpreter, - Prompt::from_args(cli.prompt), - cli.system_site_packages, - false, - )?; - Ok(()) -} - -fn main() -> ExitCode { - tracing_subscriber::registry() - .with(fmt::layer()) - .with(EnvFilter::from_default_env()) - .init(); - - let start = Instant::now(); - let result = run(); - info!("Took {}ms", start.elapsed().as_millis()); - if let Err(err) = result { - eprintln!("💥 virtualenv creator failed"); - - let mut last_error: Option<&(dyn Error + 'static)> = Some(&err); - while let Some(err) = last_error { - eprintln!(" Caused by: {err}"); - last_error = err.source(); - } - ExitCode::FAILURE - } else { - ExitCode::SUCCESS - } -}