Skip to content

Commit c84a812

Browse files
committed
Use the root project name for the project virtual environment prompt
1 parent 66699de commit c84a812

File tree

1 file changed

+20
-1
lines changed
  • crates/uv/src/commands/project

1 file changed

+20
-1
lines changed

crates/uv/src/commands/project/mod.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,29 @@ pub(crate) async fn get_or_init_environment(
401401
venv.user_display().cyan()
402402
)?;
403403

404+
// Determine a prompt for the environment, in order of preference:
405+
//
406+
// 1) The name of the project
407+
// 2) The name of the directory at the root of the workspace
408+
// 3) No prompt
409+
let prompt = workspace
410+
.pyproject_toml()
411+
.project
412+
.as_ref()
413+
.map(|p| p.name.to_string())
414+
.or_else(|| {
415+
workspace
416+
.install_path()
417+
.file_name()
418+
.map(|f| f.to_string_lossy().to_string())
419+
})
420+
.map(uv_virtualenv::Prompt::Static)
421+
.unwrap_or(uv_virtualenv::Prompt::None);
422+
404423
Ok(uv_virtualenv::create_venv(
405424
&venv,
406425
interpreter,
407-
uv_virtualenv::Prompt::None,
426+
prompt,
408427
false,
409428
false,
410429
false,

0 commit comments

Comments
 (0)