forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipEnvInstaller.ts
39 lines (34 loc) · 1.41 KB
/
pipEnvInstaller.ts
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { inject, injectable } from 'inversify';
import { Uri } from 'vscode';
import { IInterpreterLocatorService, PIPENV_SERVICE } from '../../interpreter/contracts';
import { IServiceContainer } from '../../ioc/types';
import { ExecutionInfo } from '../types';
import { ModuleInstaller } from './moduleInstaller';
import { IModuleInstaller } from './types';
export const pipenvName = 'pipenv';
@injectable()
export class PipEnvInstaller extends ModuleInstaller implements IModuleInstaller {
private readonly pipenv: IInterpreterLocatorService;
public get displayName() {
return pipenvName;
}
public get priority(): number {
return 10;
}
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
super(serviceContainer);
this.pipenv = this.serviceContainer.get<IInterpreterLocatorService>(IInterpreterLocatorService, PIPENV_SERVICE);
}
public async isSupported(resource?: Uri): Promise<boolean> {
const interpreters = await this.pipenv.getInterpreters(resource);
return interpreters && interpreters.length > 0;
}
protected async getExecutionInfo(moduleName: string, _resource?: Uri): Promise<ExecutionInfo> {
return {
args: ['install', moduleName, '--dev'],
execPath: pipenvName
};
}
}