@@ -8,6 +8,7 @@ import { traceError, traceInfo } from '../../common/logging';
88import { getWorkspacePersistentState } from '../../common/persistentState' ;
99import { getUserHomeDir , untildify } from '../../common/utils/pathUtils' ;
1010import { isWindows } from '../../common/utils/platformUtils' ;
11+ import { getConfiguration } from '../../common/workspace.apis' ;
1112import {
1213 isNativeEnvInfo ,
1314 NativeEnvInfo ,
@@ -41,6 +42,12 @@ export async function clearPoetryCache(): Promise<void> {
4142 poetryVirtualenvsPath = undefined ;
4243}
4344
45+ function getPoetryPathFromSettings ( ) : string | undefined {
46+ const config = getConfiguration ( 'python' ) ;
47+ const value = config . get < string > ( 'poetryPath' ) ;
48+ return value && typeof value === 'string' ? untildify ( value ) : value ;
49+ }
50+
4451async function setPoetry ( poetry : string ) : Promise < void > {
4552 poetryPath = poetry ;
4653 const state = await getWorkspacePersistentState ( ) ;
@@ -115,6 +122,14 @@ export async function getPoetry(native?: NativePythonFinder): Promise<string | u
115122 return untildify ( poetryPath ) ;
116123 }
117124
125+ // try to get from settings
126+ const settingPath = getPoetryPathFromSettings ( ) ;
127+ if ( settingPath ) {
128+ poetryPath = settingPath ;
129+ traceInfo ( `Using poetry from settings: ${ settingPath } ` ) ;
130+ return poetryPath ;
131+ }
132+
118133 // Check in standard PATH locations
119134 poetryPath = await findPoetry ( ) ;
120135 if ( poetryPath ) {
@@ -292,7 +307,9 @@ export async function refreshPoetry(
292307 manager : EnvironmentManager ,
293308) : Promise < PythonEnvironment [ ] > {
294309 traceInfo ( 'Refreshing poetry environments' ) ;
295- const data = await nativeFinder . refresh ( hardRefresh ) ;
310+
311+ const searchPath = getPoetryPathFromSettings ( ) ;
312+ const data = await nativeFinder . refresh ( hardRefresh , searchPath ? [ Uri . file ( searchPath ) ] : undefined ) ;
296313
297314 let poetry = await getPoetry ( ) ;
298315
0 commit comments