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

+20
Переглянути файл
@@ -823,6 +823,26 @@ export const commands = {
jdkDownload: (vendor: string, version: number, location: string | null, request: RequestId, onEvent: Channel<InstallEvent>) => typedError<Sdk, IdeError>(__TAURI_INVOKE("jdk_download", { vendor, version, location, request, onEvent })),
/** Installed interpreters / toolchains of `kind`; project-local ones first. */
sdkDetect: (kind: SdkKind) => typedError<Sdk[], IdeError>(__TAURI_INVOKE("sdk_detect", { kind })),
/** An existing Python executable or virtualenv folder as an SDK; `None` if Python cannot run. */
sdkPythonInterpreter: (path: string) => typedError<{
/**
* Executable (`python`, `node`, `pnpm`) or directory (Rust toolchain bin
* dir, GOROOT, TypeScript `lib` dir) that the setting stores.
*/
path: IpcPath,
/** Display name, e.g. `Python 3.12 (.venv)` or `stable-aarch64-apple-darwin`. */
name: string,
version: string | null,
/**
* Where it was found: `venv` | `system` | `pyenv` | `conda` | `uv` | `nvm` |
* `rustup` | `bundled` | `workspace` | `path` …
*/
source: string,
/** Environment / toolchain root (virtualenv dir, rustup toolchain dir, GOROOT). */
home: IpcPath | null,
/** Rust standard library sources, Go default GOPATH. */
extra: IpcPath | null,
} | null, IdeError>(__TAURI_INVOKE("sdk_python_interpreter", { path })),
/** The interpreter the project uses: the configured one, else its virtualenv. */
sdkPythonEffective: (near: string | null) => typedError<string | null, IdeError>(__TAURI_INVOKE("sdk_python_effective", { near })),
/** The PHP interpreter chosen in Settings › Languages & Frameworks › PHP; `None`: the `php` on `PATH`. */