diff --git a/Cargo.lock b/Cargo.lock index 82888df9e..aa48f9677 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1173,6 +1173,7 @@ dependencies = [ "anstream", "camino", "clap", + "directories", "fs-err", "platform-host", "puffin-cache", diff --git a/crates/gourgeist/Cargo.toml b/crates/gourgeist/Cargo.toml index 6f06028b0..395ee705e 100644 --- a/crates/gourgeist/Cargo.toml +++ b/crates/gourgeist/Cargo.toml @@ -13,6 +13,10 @@ repository = { workspace = true } authors = { workspace = true } license = { workspace = true } +[[bin]] +name = "gourgeist" +required-features = ["cli"] + [lints] workspace = true @@ -23,7 +27,8 @@ puffin-interpreter = { path = "../puffin-interpreter" } anstream = { workspace = true } camino = { workspace = true } -clap = { workspace = true, features = ["derive"] } +clap = { workspace = true, features = ["derive"], optional = true } +directories = { workspace = true } fs-err = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } @@ -32,3 +37,6 @@ thiserror = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true } which = { workspace = true } + +[features] +cli = ["clap"] diff --git a/crates/gourgeist/benchmark.sh b/crates/gourgeist/benchmark.sh index af1de4d12..c4d4ac3de 100644 --- a/crates/gourgeist/benchmark.sh +++ b/crates/gourgeist/benchmark.sh @@ -2,15 +2,13 @@ set -e +cd "$(git rev-parse --show-toplevel)" + virtualenv --version -#cargo build --profile profiling -cargo build --release #--features parallel -# Benchmarking trick! strip your binaries ٩( ∂‿∂ )۶ -strip target/release/gourgeist +cargo build --profile profiling --bin gourgeist --features cli -echo "## Bare" -hyperfine --warmup 1 --prepare "rm -rf target/a" "virtualenv -p 3.11 --no-seed target/a" "target/release/gourgeist -p 3.11 --bare target/a" -echo "## Default" -hyperfine --warmup 1 --prepare "rm -rf target/a" "virtualenv -p 3.11 target/a" "target/release/gourgeist -p 3.11 target/a" +hyperfine --warmup 1 --shell none --prepare "rm -rf target/venv-benchmark" \ + "target/profiling/gourgeist -p 3.11 target/venv-benchmark" \ + "virtualenv -p 3.11 --no-seed target/venv-benchmark" diff --git a/crates/gourgeist/src/main.rs b/crates/gourgeist/src/main.rs index a1411eb86..ef4c4adaa 100644 --- a/crates/gourgeist/src/main.rs +++ b/crates/gourgeist/src/main.rs @@ -5,6 +5,7 @@ use std::time::Instant; use anstream::eprintln; use camino::Utf8PathBuf; use clap::Parser; +use directories::ProjectDirs; use tracing::info; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; @@ -27,7 +28,11 @@ fn run() -> Result<(), gourgeist::Error> { let location = cli.path.unwrap_or(Utf8PathBuf::from(".venv")); let python = parse_python_cli(cli.python)?; let platform = Platform::current()?; - let cache = Cache::temp()?; + let cache = if let Some(project_dirs) = ProjectDirs::from("", "", "gourgeist") { + Cache::from_path(project_dirs.cache_dir())? + } else { + Cache::from_path(".gourgeist_cache")? + }; let info = Interpreter::query(python.as_std_path(), platform, &cache).unwrap(); create_bare_venv(&location, &info)?; Ok(())