Skip to content

Commit fc70580

Browse files
authored
include venvFolders in search paths (#802)
1 parent e81a721 commit fc70580

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/managers/common/nativePythonFinder.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { PythonProjectApi } from '../../api';
88
import { ENVS_EXTENSION_ID, PYTHON_EXTENSION_ID } from '../../common/constants';
99
import { getExtension } from '../../common/extension.apis';
1010
import { traceVerbose } from '../../common/logging';
11-
import { getUserHomeDir, untildify } from '../../common/utils/pathUtils';
11+
import { untildify } from '../../common/utils/pathUtils';
1212
import { isWindows } from '../../common/utils/platformUtils';
1313
import { createRunningWorkerPool, WorkerPool } from '../../common/utils/workerPool';
1414
import { getConfiguration } from '../../common/workspace.apis';
@@ -184,15 +184,22 @@ class NativePythonFinderImpl implements NativePythonFinder {
184184
}
185185

186186
private getRefreshOptions(options?: NativePythonEnvironmentKind | Uri[]): RefreshOptions | undefined {
187+
// settings on where else to search
188+
const venvFolders = getPythonSettingAndUntildify<string[]>('venvFolders') ?? [];
187189
if (options) {
188190
if (typeof options === 'string') {
191+
// kind
189192
return { searchKind: options };
190193
}
191194
if (Array.isArray(options)) {
192-
return { searchPaths: options.map((item) => item.fsPath) };
195+
const uriSearchPaths = options.map((item) => item.fsPath);
196+
uriSearchPaths.push(...venvFolders);
197+
return { searchPaths: uriSearchPaths };
193198
}
199+
} else {
200+
// if no options, then search venvFolders
201+
return { searchPaths: venvFolders };
194202
}
195-
return undefined;
196203
}
197204

198205
private start(): rpc.MessageConnection {
@@ -355,10 +362,9 @@ function getCustomVirtualEnvDirs(): string[] {
355362
venvDirs.push(untildify(venvPath));
356363
}
357364
const venvFolders = getPythonSettingAndUntildify<string[]>('venvFolders') ?? [];
358-
const homeDir = getUserHomeDir();
359-
if (homeDir) {
360-
venvFolders.map((item) => path.join(homeDir, item)).forEach((d) => venvDirs.push(d));
361-
}
365+
venvFolders.forEach((item) => {
366+
venvDirs.push(item);
367+
});
362368
return Array.from(new Set(venvDirs));
363369
}
364370

0 commit comments

Comments
 (0)