Gourgeist updates (#862)

* Use caching again
* Make clap feature only required for the cli/bin optional
This commit is contained in:
konsti 2024-01-10 00:04:15 +01:00 committed by GitHub
parent e67b7858e6
commit 1203f8f9e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 10 deletions

View file

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

View file

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

View file

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