feat(interpreters): add an existing Python virtual environment as an interpreter (#2076)

Refs #1907

Add Python Interpreter → Existing environment: Browse picks the environment folder, which is resolved right away (pyvenv.cfg, bin/python or Scripts\python.exe) and added to the interpreter list as "Python X.Y (<env name>)", then remembered. Picking the folder rather than the executable keeps the environment's identity, since the native file picker resolves the venv's python symlink to the base interpreter. Works for `python -m venv` and uv environments; a broken environment shows an error instead of being added. Probing runs off the command thread.

Co-authored-by: Inf1mum <[email protected]>
Цей коміт міститься в:
Vadim LazukтаInf1mum authored and GitHub committed 2026-11-08 09:32:37 +08:00
1 джерело 9673ccc687
коміт 32a778d28d
13 files changed
+430 -25

No files matched your search

+1
Переглянути файл
@@ -411,6 +411,7 @@ pub fn builder() -> tauri_specta::Builder<tauri::Wry> {
tools::jdk_download_location,
tools::jdk_download,
sdk::sdk_detect,
sdk::sdk_python_interpreter,
sdk::sdk_python_effective,
sdk::sdk_php_effective,
sdk::sdk_php_xdebug,
+11
Переглянути файл
@@ -96,6 +96,17 @@ pub async fn sdk_locate_tools(
ide_host::ops::sdk::sdk_locate_tools(&state.host, window.label(), names, near).await
}
/// An existing Python executable or virtualenv folder as an SDK; `None` if Python cannot run.
#[tauri::command]
#[specta::specta]
pub async fn sdk_python_interpreter(
window: Window,
state: State<'_, AppState>,
path: PathBuf,
) -> IdeResult<Option<Sdk>> {
ide_host::ops::sdk::sdk_python_interpreter(&state.host, window.label(), path).await
}
/// Creates a Python environment with `tool` (`venv` / `uv` / `poetry`); output streams through `on_output`.
#[tauri::command]
#[specta::specta]