Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/managers/builtin/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '../../api';
import { showErrorMessageWithLogs } from '../../common/errors/utils';
import { SysManagerStrings } from '../../common/localize';
import { traceVerbose } from '../../common/logging';
import { withProgress } from '../../common/window.apis';
import {
isNativeEnvInfo,
Expand Down Expand Up @@ -299,11 +300,16 @@ export async function resolveSystemPythonEnvironmentPath(
api: PythonEnvironmentApi,
manager: EnvironmentManager,
): Promise<PythonEnvironment | undefined> {
const resolved = await nativeFinder.resolve(fsPath);
try {
const resolved = await nativeFinder.resolve(fsPath);

// This is supposed to handle a python interpreter as long as we know some basic things about it
if (resolved.executable && resolved.version && resolved.prefix) {
const envInfo = getPythonInfo(resolved);
return api.createPythonEnvironmentItem(envInfo, manager);
// This is supposed to handle a python interpreter as long as we know some basic things about it
if (resolved.executable && resolved.version && resolved.prefix) {
const envInfo = getPythonInfo(resolved);
return api.createPythonEnvironmentItem(envInfo, manager);
}
} catch (ex) {
traceVerbose(`Failed to resolve env "${fsPath}": ${ex}`);
}
return undefined;
}
24 changes: 14 additions & 10 deletions src/managers/builtin/venvUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { l10n, LogOutputChannel, ProgressLocation, QuickPickItem, QuickPickItemK
import { EnvironmentManager, PythonEnvironment, PythonEnvironmentApi, PythonEnvironmentInfo } from '../../api';
import { ENVS_EXTENSION_ID } from '../../common/constants';
import { Common, VenvManagerStrings } from '../../common/localize';
import { traceInfo } from '../../common/logging';
import { traceInfo, traceVerbose } from '../../common/logging';
import { getWorkspacePersistentState } from '../../common/persistentState';
import { EventNames } from '../../common/telemetry/constants';
import { sendTelemetryEvent } from '../../common/telemetry/sender';
Expand Down Expand Up @@ -581,15 +581,19 @@ export async function resolveVenvPythonEnvironmentPath(
manager: EnvironmentManager,
baseManager: EnvironmentManager,
): Promise<PythonEnvironment | undefined> {
const resolved = await nativeFinder.resolve(fsPath);

if (
resolved.kind === NativePythonEnvironmentKind.venv ||
resolved.kind === NativePythonEnvironmentKind.venvUv ||
resolved.kind === NativePythonEnvironmentKind.uvWorkspace
) {
const envInfo = await getPythonInfo(resolved);
return api.createPythonEnvironmentItem(envInfo, manager);
try {
const resolved = await nativeFinder.resolve(fsPath);

if (
resolved.kind === NativePythonEnvironmentKind.venv ||
resolved.kind === NativePythonEnvironmentKind.venvUv ||
resolved.kind === NativePythonEnvironmentKind.uvWorkspace
) {
const envInfo = await getPythonInfo(resolved);
return api.createPythonEnvironmentItem(envInfo, manager);
}
} catch (ex) {
traceVerbose(`Failed to resolve venv env "${fsPath}": ${ex}`);
}

return resolveSystemPythonEnvironmentPath(fsPath, nativeFinder, api, baseManager);
Expand Down
16 changes: 10 additions & 6 deletions src/managers/pipenv/pipenvUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
PythonEnvironmentInfo,
} from '../../api';
import { ENVS_EXTENSION_ID } from '../../common/constants';
import { traceError, traceInfo } from '../../common/logging';
import { traceError, traceInfo, traceVerbose } from '../../common/logging';
import { getWorkspacePersistentState } from '../../common/persistentState';
import { untildify } from '../../common/utils/pathUtils';
import { getSettingWorkspaceScope } from '../../features/settings/settingHelpers';
Expand Down Expand Up @@ -222,12 +222,16 @@ export async function resolvePipenvPath(
api: PythonEnvironmentApi,
manager: EnvironmentManager,
): Promise<PythonEnvironment | undefined> {
const resolved = await nativeFinder.resolve(fsPath);
try {
const resolved = await nativeFinder.resolve(fsPath);

// Resolve pipenv environments even if the pipenv CLI is not found.
// This allows proper environment identification for read-only scenarios.
if (resolved.kind === NativePythonEnvironmentKind.pipenv) {
return await nativeToPythonEnv(resolved, api, manager);
// Resolve pipenv environments even if the pipenv CLI is not found.
// This allows proper environment identification for read-only scenarios.
if (resolved.kind === NativePythonEnvironmentKind.pipenv) {
return await nativeToPythonEnv(resolved, api, manager);
}
} catch (ex) {
traceVerbose(`Failed to resolve pipenv env "${fsPath}": ${ex}`);
}

return undefined;
Expand Down
Loading