Skip to content

Commit 8813abe

Browse files
authored
Enable terminal activation for uv-managed environments (#45949)
Currently, the Python toolchain can identify `uv` and `uv-workspace` environments (showing the correct labels in the UI), but it fails to activate them when opening a new terminal. This is because the activation script resolution and command generation logic were missing for these environment kinds. This PR adds `uv` and `uv-workspace` to the standard virtual environment activation flow. Since `uv` creates environments with a standard `venv` structure, we can reuse the existing `resolve_venv_activation_scripts` logic to find and execute the appropriate `activate` scripts for different shells. Release Notes: - Fixed terminal activation for `uv` and `uv-workspace` Python environments.
1 parent 01b716c commit 8813abe

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

crates/languages/src/python.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,12 @@ impl ToolchainLister for PythonToolchainProvider {
13581358
activation_script.push(format!("{manager} activate base"));
13591359
}
13601360
}
1361-
Some(PythonEnvironmentKind::Venv | PythonEnvironmentKind::VirtualEnv) => {
1361+
Some(
1362+
PythonEnvironmentKind::Venv
1363+
| PythonEnvironmentKind::VirtualEnv
1364+
| PythonEnvironmentKind::Uv
1365+
| PythonEnvironmentKind::UvWorkspace,
1366+
) => {
13621367
if let Some(activation_scripts) = &toolchain.activation_scripts {
13631368
if let Some(activate_script_path) = activation_scripts.get(&shell) {
13641369
let activate_keyword = shell.activate_keyword();
@@ -1415,9 +1420,12 @@ async fn venv_to_toolchain(venv: PythonEnvironment, fs: &dyn Fs) -> Option<Toolc
14151420

14161421
let mut activation_scripts = HashMap::default();
14171422
match venv.kind {
1418-
Some(PythonEnvironmentKind::Venv | PythonEnvironmentKind::VirtualEnv) => {
1419-
resolve_venv_activation_scripts(&venv, fs, &mut activation_scripts).await
1420-
}
1423+
Some(
1424+
PythonEnvironmentKind::Venv
1425+
| PythonEnvironmentKind::VirtualEnv
1426+
| PythonEnvironmentKind::Uv
1427+
| PythonEnvironmentKind::UvWorkspace,
1428+
) => resolve_venv_activation_scripts(&venv, fs, &mut activation_scripts).await,
14211429
_ => {}
14221430
}
14231431
let data = PythonToolchainData {

0 commit comments

Comments
 (0)