forked from microsoft/vscode-python-environments
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
42 lines (37 loc) · 1.78 KB
/
main.ts
File metadata and controls
42 lines (37 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Disposable, LogOutputChannel } from 'vscode';
import { PythonEnvironmentApi } from '../../api';
import { traceInfo } from '../../common/logging';
import { getPythonApi } from '../../features/pythonApi';
import { PythonProjectManager } from '../../internal.api';
import { NativePythonFinder } from '../common/nativePythonFinder';
import { notifyMissingManagerIfDefault } from '../common/utils';
import { CondaEnvManager } from './condaEnvManager';
import { CondaPackageManager } from './condaPackageManager';
import { CondaSourcingStatus, constructCondaSourcingStatus } from './condaSourcingUtils';
import { getConda } from './condaUtils';
export async function registerCondaFeatures(
nativeFinder: NativePythonFinder,
disposables: Disposable[],
log: LogOutputChannel,
projectManager: PythonProjectManager,
): Promise<void> {
const api: PythonEnvironmentApi = await getPythonApi();
try {
// get Conda will return only ONE conda manager, that correlates to a single conda install
const condaPath: string = await getConda(nativeFinder);
const sourcingStatus: CondaSourcingStatus = await constructCondaSourcingStatus(condaPath);
traceInfo(sourcingStatus.toString());
const envManager = new CondaEnvManager(nativeFinder, api, log);
const packageManager = new CondaPackageManager(api, log);
envManager.sourcingInformation = sourcingStatus;
disposables.push(
envManager,
packageManager,
api.registerEnvironmentManager(envManager),
api.registerPackageManager(packageManager),
);
} catch (ex) {
traceInfo('Conda not found, turning off conda features.', ex);
await notifyMissingManagerIfDefault('ms-python.python:conda', projectManager, api);
}
}