Skip to content
Merged
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
19 changes: 18 additions & 1 deletion src/managers/poetry/poetryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { traceError, traceInfo } from '../../common/logging';
import { getWorkspacePersistentState } from '../../common/persistentState';
import { getUserHomeDir, untildify } from '../../common/utils/pathUtils';
import { isWindows } from '../../common/utils/platformUtils';
import { getConfiguration } from '../../common/workspace.apis';
import {
isNativeEnvInfo,
NativeEnvInfo,
Expand Down Expand Up @@ -41,6 +42,12 @@ export async function clearPoetryCache(): Promise<void> {
poetryVirtualenvsPath = undefined;
}

function getPoetryPathFromSettings(): string | undefined {
const config = getConfiguration('python');
const value = config.get<string>('poetryPath');
return value && typeof value === 'string' ? untildify(value) : value;
}

async function setPoetry(poetry: string): Promise<void> {
poetryPath = poetry;
const state = await getWorkspacePersistentState();
Expand Down Expand Up @@ -115,6 +122,14 @@ export async function getPoetry(native?: NativePythonFinder): Promise<string | u
return untildify(poetryPath);
}

// try to get from settings
const settingPath = getPoetryPathFromSettings();
if (settingPath) {
poetryPath = settingPath;
traceInfo(`Using poetry from settings: ${settingPath}`);
return poetryPath;
}

// Check in standard PATH locations
poetryPath = await findPoetry();
if (poetryPath) {
Expand Down Expand Up @@ -292,7 +307,9 @@ export async function refreshPoetry(
manager: EnvironmentManager,
): Promise<PythonEnvironment[]> {
traceInfo('Refreshing poetry environments');
const data = await nativeFinder.refresh(hardRefresh);

const searchPath = getPoetryPathFromSettings();
const data = await nativeFinder.refresh(hardRefresh, searchPath ? [Uri.file(searchPath)] : undefined);

let poetry = await getPoetry();

Expand Down
Loading