Canonicalize virtualenv path once (#678)

This avoids filesystem calls when creating a `BuildDispatch`.

Co-authored-by: konsti <konstin@mailbox.org>
This commit is contained in:
Charlie Marsh
2023-12-18 09:42:58 -05:00
committed by GitHub
parent 89ca0d68b9
commit 74ca9128b4
7 changed files with 8 additions and 9 deletions
@@ -142,7 +142,7 @@ pub(crate) async fn pip_compile(
client.clone(),
cache.clone(),
interpreter,
fs_err::canonicalize(venv.python_executable())?,
venv.python_executable(),
no_build,
index_urls,
)
@@ -4,7 +4,6 @@ use std::path::Path;
use anyhow::{anyhow, bail, Context, Result};
use chrono::{DateTime, Utc};
use colored::Colorize;
use fs_err as fs;
use itertools::Itertools;
use tempfile::tempdir_in;
use tracing::debug;
@@ -137,7 +136,7 @@ pub(crate) async fn pip_install(
client.clone(),
cache.clone(),
interpreter,
fs::canonicalize(venv.python_executable())?,
venv.python_executable(),
no_build,
index_urls.clone(),
)
+1 -2
View File
@@ -2,7 +2,6 @@ use std::fmt::Write;
use anyhow::{bail, Context, Result};
use colored::Colorize;
use fs_err as fs;
use itertools::Itertools;
use tracing::debug;
@@ -66,7 +65,7 @@ pub(crate) async fn pip_sync(
client.clone(),
cache.clone(),
venv.interpreter().clone(),
fs::canonicalize(venv.python_executable())?,
venv.python_executable(),
no_build,
index_urls.clone(),
);
+1 -1
View File
@@ -58,7 +58,7 @@ pub(crate) async fn build(args: BuildArgs) -> Result<PathBuf> {
RegistryClientBuilder::new(cache.clone()).build(),
cache,
venv.interpreter().clone(),
fs::canonicalize(venv.python_executable())?,
venv.python_executable(),
false,
IndexUrls::default(),
);
+2 -2
View File
@@ -5,7 +5,7 @@ use anstream::println;
use anyhow::{Context, Result};
use chrono::{DateTime, Utc};
use clap::{Parser, ValueEnum};
use fs_err as fs;
use fs_err::File;
use itertools::Itertools;
use petgraph::dot::{Config as DotConfig, Dot};
@@ -55,7 +55,7 @@ pub(crate) async fn resolve_cli(args: ResolveCliArgs) -> Result<()> {
client.clone(),
cache.clone(),
venv.interpreter().clone(),
fs::canonicalize(venv.python_executable())?,
venv.python_executable(),
args.no_build,
IndexUrls::default(),
);
+1 -1
View File
@@ -56,7 +56,7 @@ pub(crate) async fn resolve_many(args: ResolveManyArgs) -> Result<()> {
RegistryClientBuilder::new(cache.clone()).build(),
cache.clone(),
venv.interpreter().clone(),
fs::canonicalize(venv.python_executable())?,
venv.python_executable(),
args.no_build,
IndexUrls::default(),
);
@@ -24,6 +24,7 @@ impl Virtualenv {
let Some(venv) = detect_virtual_env(&platform)? else {
return Err(Error::NotFound);
};
let venv = fs_err::canonicalize(venv)?;
let executable = platform.venv_python(&venv);
let interpreter = Interpreter::query(&executable, platform.0, cache)?;