Use cached current directory everywhere (#5574)

This commit is contained in:
Charlie Marsh 2024-07-29 17:03:45 -04:00 committed by GitHub
parent 37388f0987
commit 51a03738a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 43 additions and 45 deletions

View file

@ -1,6 +1,5 @@
//! Create a virtual environment.
use std::env;
use std::env::consts::EXE_SUFFIX;
use std::io;
use std::io::{BufWriter, Write};
@ -12,7 +11,7 @@ use itertools::Itertools;
use tracing::info;
use pypi_types::Scheme;
use uv_fs::{cachedir, Simplified};
use uv_fs::{cachedir, Simplified, CWD};
use uv_python::{Interpreter, VirtualEnvironment};
use uv_version::version;
@ -131,7 +130,7 @@ pub(crate) fn create(
};
let scripts = location.join(&interpreter.virtualenv().scripts);
let prompt = match prompt {
Prompt::CurrentDirectoryName => env::current_dir()?
Prompt::CurrentDirectoryName => CWD
.file_name()
.map(|name| name.to_string_lossy().to_string()),
Prompt::Static(value) => Some(value),