Skip to content

Commit 5b6c99b

Browse files
author
Kartik Raj
authored
Remove poetry watcher (microsoft#20404)
Closes microsoft#17087
1 parent 5e83629 commit 5b6c99b

2 files changed

Lines changed: 3 additions & 96 deletions

File tree

src/client/pythonEnvironments/base/locators/lowLevel/poetryLocator.ts

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import * as path from 'path';
77
import { chain, iterable } from '../../../../common/utils/async';
88
import { PythonEnvKind } from '../../info';
99
import { BasicEnvInfo, IPythonEnvsIterator } from '../../locator';
10-
import { FSWatcherKind, FSWatchingLocator } from './fsWatchingLocator';
1110
import { getInterpreterPathFromDir } from '../../../common/commonUtils';
1211
import { pathExists } from '../../../common/externalDependencies';
1312
import { isPoetryEnvironment, localPoetryEnvDirName, Poetry } from '../../../common/environmentManagers/poetry';
1413
import '../../../../common/extensions';
1514
import { asyncFilter } from '../../../../common/utils/arrayUtils';
1615
import { traceError, traceVerbose } from '../../../../logging';
16+
import { LazyResourceBasedLocator } from '../common/resourceBasedLocator';
1717

1818
/**
1919
* Gets all default virtual environment locations to look for in a workspace.
@@ -28,27 +28,6 @@ async function getVirtualEnvDirs(root: string): Promise<string[]> {
2828
return asyncFilter(envDirs, pathExists);
2929
}
3030

31-
async function getRootVirtualEnvDir(root: string): Promise<string[]> {
32-
const rootDirs = [];
33-
const poetry = await Poetry.getPoetry(root);
34-
/**
35-
* We can infer the directory in which the existing poetry environments are created to determine
36-
* the root virtual env dir. If no virtual envs are created yet, then fetch the setting value to
37-
* get the root directory instead. We prefer to use 'poetry env list' command first because the
38-
* result of that command is already cached when getting poetry.
39-
*/
40-
const virtualenvs = await poetry?.getEnvList();
41-
if (virtualenvs?.length) {
42-
rootDirs.push(path.dirname(virtualenvs[0]));
43-
} else {
44-
const setting = await poetry?.getVirtualenvsPathSetting();
45-
if (setting) {
46-
rootDirs.push(setting);
47-
}
48-
}
49-
return rootDirs;
50-
}
51-
5231
async function getVirtualEnvKind(interpreterPath: string): Promise<PythonEnvKind> {
5332
if (await isPoetryEnvironment(interpreterPath)) {
5433
return PythonEnvKind.Poetry;
@@ -60,16 +39,11 @@ async function getVirtualEnvKind(interpreterPath: string): Promise<PythonEnvKind
6039
/**
6140
* Finds and resolves virtual environments created using poetry.
6241
*/
63-
export class PoetryLocator extends FSWatchingLocator {
42+
export class PoetryLocator extends LazyResourceBasedLocator {
6443
public readonly providerId: string = 'poetry';
6544

6645
public constructor(private readonly root: string) {
67-
super(
68-
() => getRootVirtualEnvDir(root),
69-
async () => PythonEnvKind.Poetry,
70-
undefined,
71-
FSWatcherKind.Workspace,
72-
);
46+
super();
7347
}
7448

7549
protected doIterEnvs(): IPythonEnvsIterator<BasicEnvInfo> {

src/test/pythonEnvironments/base/locators/lowLevel/poetryLocator.testvirtualenvs.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)