diff --git a/src/managers/poetry/poetryUtils.ts b/src/managers/poetry/poetryUtils.ts index 08860972..50b1ecc6 100644 --- a/src/managers/poetry/poetryUtils.ts +++ b/src/managers/poetry/poetryUtils.ts @@ -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, @@ -41,6 +42,12 @@ export async function clearPoetryCache(): Promise { poetryVirtualenvsPath = undefined; } +function getPoetryPathFromSettings(): string | undefined { + const config = getConfiguration('python'); + const value = config.get('poetryPath'); + return value && typeof value === 'string' ? untildify(value) : value; +} + async function setPoetry(poetry: string): Promise { poetryPath = poetry; const state = await getWorkspacePersistentState(); @@ -115,6 +122,14 @@ export async function getPoetry(native?: NativePythonFinder): Promise { 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();