Skip to content
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ecc1ca9
Fix Microsoft/vscode#37627 (#1368)
octref Nov 3, 2017
7c5778c
Version 0.7.0 of extension (#1381)
DonJayamanne Nov 9, 2017
9d1bf82
Update README.md
DonJayamanne Nov 9, 2017
ffba179
Update README.md
DonJayamanne Nov 9, 2017
905c713
sync fork with upstream
DonJayamanne Nov 10, 2017
acc2109
fix readme
DonJayamanne Nov 10, 2017
d470523
Merge branch 'master' of https://github.com/Microsoft/vscode-python
DonJayamanne Nov 16, 2017
d392e8b
merged upstream
DonJayamanne Nov 16, 2017
92f775f
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 20, 2017
32a6e53
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 21, 2017
4b30f2c
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 22, 2017
e396752
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 22, 2017
eff4792
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
4553c28
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
3c6520a
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
966e516
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
63d2d65
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
f6d469e
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
029e055
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 30, 2017
e8c71c0
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 30, 2017
51cf9d2
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 1, 2017
7aadc43
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 1, 2017
f0f5c59
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 4, 2017
b2b9da9
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 4, 2017
30a4091
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 5, 2017
b16d2f9
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 6, 2017
c8db345
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 7, 2017
0df7f16
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 8, 2017
3ccc881
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 9, 2017
bb0709e
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 11, 2017
2c19004
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 11, 2017
8f224ab
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 11, 2017
41b7080
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 12, 2017
dab38dc
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 12, 2017
ae22dd4
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 12, 2017
d2340d2
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 14, 2017
52bb7ae
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 15, 2017
b6b2531
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 19, 2017
8d8d2fc
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 19, 2017
c425a55
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 3, 2018
3963217
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 3, 2018
a696f2a
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 3, 2018
a31e659
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 4, 2018
2663cd5
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 4, 2018
7c85e0b
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 5, 2018
beb82c2
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 9, 2018
01e722a
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 10, 2018
d84da8e
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 17, 2018
78da3e1
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 19, 2018
685b683
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 23, 2018
43364fd
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 23, 2018
8701636
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 24, 2018
5c8addf
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 25, 2018
588c2f9
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 30, 2018
66b1382
Merge branch 'master' of https://github.com/DonJayamanne/pythonVSCode
DonJayamanne Jan 30, 2018
e6b4b48
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 31, 2018
9d84db2
experimental quick load
DonJayamanne Jan 31, 2018
f1b94a3
experimental quick load
DonJayamanne Jan 31, 2018
069afa3
experimental quick load
DonJayamanne Jan 31, 2018
62ede24
experimental quick load
DonJayamanne Jan 31, 2018
20f429c
experimental quick load
DonJayamanne Jan 31, 2018
a542a48
add license header
DonJayamanne Jan 31, 2018
0372b2d
cache key property
DonJayamanne Feb 1, 2018
5c733f4
await on updates to persistent store
DonJayamanne Feb 1, 2018
60e79bc
remove string interpolation
DonJayamanne Feb 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/client/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export class BannerService {
if (!this.shouldShowBanner.value) {
return;
}
this.shouldShowBanner.value = false;
this.shouldShowBanner.updateValue(false)
.catch(ex => console.error('Python Extension: Failed to update banner value', ex));

const message = 'The Python extension is now published by Microsoft!';
const yesButton = 'Read more';
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/featureDeprecationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class FeatureDeprecationManager implements IFeatureDeprecationManager {
break;
}
case doNotShowAgain: {
notificationPromptEnabled.value = false;
await notificationPromptEnabled.updateValue(false);
break;
}
default: {
Expand Down
4 changes: 2 additions & 2 deletions src/client/common/persistentState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class PersistentState<T> implements IPersistentState<T>{
return this.storage.get<T>(this.key, this.defaultValue);
}

public set value(newValue: T) {
this.storage.update(this.key, newValue);
public async updateValue(newValue: T): Promise<void> {
await this.storage.update(this.key, newValue);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/client/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export const GLOBAL_MEMENTO = Symbol('IGlobalMemento');
export const WORKSPACE_MEMENTO = Symbol('IWorkspaceMemento');

export interface IPersistentState<T> {
value: T;
readonly value: T;
updateValue(value: T): Promise<void>;
}

export const IPersistentStateFactory = Symbol('IPersistentStateFactory');
Expand Down
3 changes: 2 additions & 1 deletion src/client/interpreter/configuration/interpreterSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ export class InterpreterSelector implements Disposable {
if (workspaceUri && suggestion.path.startsWith(workspaceUri.fsPath)) {
detail = `.${path.sep}${path.relative(workspaceUri.fsPath, suggestion.path)}`;
}
const cachedPrefix = suggestion.cachedEntry ? '(cached) ' : '';
return {
// tslint:disable-next-line:no-non-null-assertion
label: suggestion.displayName!,
description: suggestion.companyDisplayName || '',
detail: detail,
detail: `${cachedPrefix}${detail}`,
path: suggestion.path
};
}
Expand Down
1 change: 1 addition & 0 deletions src/client/interpreter/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export type PythonInterpreter = {
type: InterpreterType;
envName?: string;
envPath?: string;
cachedEntry?: boolean;
};

export type WorkspacePythonPath = {
Expand Down
2 changes: 1 addition & 1 deletion src/client/interpreter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class InterpreterManager implements Disposable, IInterpreterService {
}
const virtualEnvMgr = this.serviceContainer.get<IVirtualEnvironmentManager>(IVirtualEnvironmentManager);
const versionService = this.serviceContainer.get<IInterpreterVersionService>(IInterpreterVersionService);
const virtualEnvInterpreterProvider = new VirtualEnvService([activeWorkspace.folderUri.fsPath], virtualEnvMgr, versionService);
const virtualEnvInterpreterProvider = new VirtualEnvService([activeWorkspace.folderUri.fsPath], virtualEnvMgr, versionService, this.serviceContainer);
const interpreters = await virtualEnvInterpreterProvider.getInterpreters(activeWorkspace.folderUri);
const workspacePathUpper = activeWorkspace.folderUri.fsPath.toUpperCase();

Expand Down
22 changes: 4 additions & 18 deletions src/client/interpreter/locators/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { inject, injectable } from 'inversify';
import * as _ from 'lodash';
import * as path from 'path';
import { Disposable, Uri, workspace } from 'vscode';
import { Disposable, Uri } from 'vscode';
import { IPlatformService } from '../../common/platform/types';
import { IDisposableRegistry } from '../../common/types';
import { arePathsSame } from '../../common/utils';
Expand All @@ -21,35 +21,21 @@ import { fixInterpreterDisplayName } from './helpers';

@injectable()
export class PythonInterpreterLocatorService implements IInterpreterLocatorService {
private interpretersPerResource: Map<string, Promise<PythonInterpreter[]>>;
private disposables: Disposable[] = [];
private platform: IPlatformService;

constructor( @inject(IServiceContainer) private serviceContainer: IServiceContainer) {
this.interpretersPerResource = new Map<string, Promise<PythonInterpreter[]>>();
serviceContainer.get<Disposable[]>(IDisposableRegistry).push(this);
this.platform = serviceContainer.get<IPlatformService>(IPlatformService);
}
public async getInterpreters(resource?: Uri) {
const resourceKey = this.getResourceKey(resource);
if (!this.interpretersPerResource.has(resourceKey)) {
this.interpretersPerResource.set(resourceKey, this.getInterpretersPerResource(resource));
}

return await this.interpretersPerResource.get(resourceKey)!;
return this.getInterpretersPerResource(resource);
}
public dispose() {
this.disposables.forEach(disposable => disposable.dispose());
}
private getResourceKey(resource?: Uri) {
if (!resource) {
return '';
}
const workspaceFolder = workspace.getWorkspaceFolder(resource);
return workspaceFolder ? workspaceFolder.uri.fsPath : '';
}
private async getInterpretersPerResource(resource?: Uri) {
const locators = this.getLocators(resource);
const locators = this.getLocators();
const promises = locators.map(async provider => provider.getInterpreters(resource));
const listOfInterpreters = await Promise.all(promises);

Expand All @@ -73,7 +59,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
return accumulator;
}, []);
}
private getLocators(resource?: Uri) {
private getLocators() {
const locators: IInterpreterLocatorService[] = [];
// The order of the services is important.
if (this.platform.isWindows) {
Expand Down
16 changes: 10 additions & 6 deletions src/client/interpreter/locators/services/KnownPathsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@ import * as _ from 'lodash';
import * as path from 'path';
import { Uri } from 'vscode';
import { fsExistsAsync, IS_WINDOWS } from '../../../common/utils';
import { IInterpreterLocatorService, IInterpreterVersionService, IKnownSearchPathsForInterpreters, InterpreterType } from '../../contracts';
import { IServiceContainer } from '../../../ioc/types';
import { IInterpreterVersionService, IKnownSearchPathsForInterpreters, InterpreterType, PythonInterpreter } from '../../contracts';
import { lookForInterpretersInDirectory } from '../helpers';
import { CacheableLocatorService } from './cacheableLocatorService';

// tslint:disable-next-line:no-require-imports no-var-requires
const untildify = require('untildify');

@injectable()
export class KnownPathsService implements IInterpreterLocatorService {
export class KnownPathsService extends CacheableLocatorService {
public constructor( @inject(IKnownSearchPathsForInterpreters) private knownSearchPaths: string[],
@inject(IInterpreterVersionService) private versionProvider: IInterpreterVersionService) { }
// tslint:disable-next-line:no-shadowed-variable
public getInterpreters(_?: Uri) {
return this.suggestionsFromKnownPaths();
@inject(IInterpreterVersionService) private versionProvider: IInterpreterVersionService,
@inject(IServiceContainer) serviceContainer: IServiceContainer) {
super('KnownPathsService', serviceContainer);
}
// tslint:disable-next-line:no-empty
public dispose() { }
protected getInterpretersImplementation(resource?: Uri): Promise<PythonInterpreter[]> {
return this.suggestionsFromKnownPaths();
}
private suggestionsFromKnownPaths() {
const promises = this.knownSearchPaths.map(dir => this.getInterpretersInDirectory(dir));
return Promise.all<string[]>(promises)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { injectable } from 'inversify';
import { Uri } from 'vscode';
import { createDeferred, Deferred } from '../../../common/helpers';
import { IPersistentStateFactory } from '../../../common/types';
import { IServiceContainer } from '../../../ioc/types';
import { IInterpreterLocatorService, PythonInterpreter } from '../../contracts';

@injectable()
export abstract class CacheableLocatorService implements IInterpreterLocatorService {
private getInterpretersPromise: Deferred<PythonInterpreter[]>;
private readonly cacheKey: string;
constructor(name: string,
protected readonly serviceContainer: IServiceContainer) {
this.cacheKey = `INTERPRETERS_CACHE_${name}`;
}
public abstract dispose();
public async getInterpreters(resource?: Uri): Promise<PythonInterpreter[]> {
if (!this.getInterpretersPromise) {
this.getInterpretersPromise = createDeferred<PythonInterpreter[]>();
this.getInterpretersImplementation(resource)
.then(async items => {
await this.cacheInterpreters(items);
this.getInterpretersPromise.resolve(items);
})
.catch(ex => this.getInterpretersPromise.reject(ex));
}
if (this.getInterpretersPromise.completed) {
return this.getInterpretersPromise.promise;
}

const cachedInterpreters = this.getCachedInterpreters();
return Array.isArray(cachedInterpreters) ? cachedInterpreters : this.getInterpretersPromise.promise;
}

protected abstract getInterpretersImplementation(resource?: Uri): Promise<PythonInterpreter[]>;

private getCachedInterpreters() {
const persistentFactory = this.serviceContainer.get<IPersistentStateFactory>(IPersistentStateFactory);
// tslint:disable-next-line:no-any
const globalPersistence = persistentFactory.createGlobalPersistentState<PythonInterpreter[]>(`${this.cacheKey}`, undefined as any);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the call use `${this.cacheKey}` instead of just this.cacheKey as a direct argument?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left overs of code refactoring.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn another commit, another round of travis tests.

if (!Array.isArray(globalPersistence.value)) {
return;
}
return globalPersistence.value.map(item => {
return {
...item,
cachedEntry: true
};
});
}
private async cacheInterpreters(interpreters: PythonInterpreter[]) {
const persistentFactory = this.serviceContainer.get<IPersistentStateFactory>(IPersistentStateFactory);
const globalPersistence = persistentFactory.createGlobalPersistentState<PythonInterpreter[]>(`${this.cacheKey}`, []);
await globalPersistence.updateValue(interpreters);
}
}
13 changes: 8 additions & 5 deletions src/client/interpreter/locators/services/condaEnvFileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@ import * as path from 'path';
import { Uri } from 'vscode';
import { IFileSystem } from '../../../common/platform/types';
import { ILogger } from '../../../common/types';
import { IServiceContainer } from '../../../ioc/types';
import {
ICondaService,
IInterpreterLocatorService,
IInterpreterVersionService,
InterpreterType,
PythonInterpreter
} from '../../contracts';
import { CacheableLocatorService } from './cacheableLocatorService';
import { AnacondaCompanyName, AnacondaCompanyNames, AnacondaDisplayName } from './conda';

@injectable()
export class CondaEnvFileService implements IInterpreterLocatorService {
export class CondaEnvFileService extends CacheableLocatorService {
constructor( @inject(IInterpreterVersionService) private versionService: IInterpreterVersionService,
@inject(ICondaService) private condaService: ICondaService,
@inject(IFileSystem) private fileSystem: IFileSystem,
@inject(IServiceContainer) serviceContainer: IServiceContainer,
@inject(ILogger) private logger: ILogger) {
}
public async getInterpreters(_?: Uri) {
return this.getSuggestionsFromConda();
super('CondaEnvFileService', serviceContainer);
}
// tslint:disable-next-line:no-empty
public dispose() { }
protected getInterpretersImplementation(resource?: Uri): Promise<PythonInterpreter[]> {
return this.getSuggestionsFromConda();
}
private async getSuggestionsFromConda(): Promise<PythonInterpreter[]> {
if (!this.condaService.condaEnvironmentsFile) {
return [];
Expand Down
14 changes: 9 additions & 5 deletions src/client/interpreter/locators/services/condaEnvService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ import { inject, injectable } from 'inversify';
import { Uri } from 'vscode';
import { IFileSystem } from '../../../common/platform/types';
import { ILogger } from '../../../common/types';
import { CondaInfo, ICondaService, IInterpreterLocatorService, IInterpreterVersionService, InterpreterType, PythonInterpreter } from '../../contracts';
import { IServiceContainer } from '../../../ioc/types';
import { CondaInfo, ICondaService, IInterpreterVersionService, InterpreterType, PythonInterpreter } from '../../contracts';
import { CacheableLocatorService } from './cacheableLocatorService';
import { AnacondaCompanyName, AnacondaCompanyNames } from './conda';
import { CondaHelper } from './condaHelper';

@injectable()
export class CondaEnvService implements IInterpreterLocatorService {
export class CondaEnvService extends CacheableLocatorService {
private readonly condaHelper = new CondaHelper();
constructor( @inject(ICondaService) private condaService: ICondaService,
@inject(IInterpreterVersionService) private versionService: IInterpreterVersionService,
@inject(ILogger) private logger: ILogger,
@inject(IServiceContainer) serviceContainer: IServiceContainer,
@inject(IFileSystem) private fileSystem: IFileSystem) {
}
public async getInterpreters(resource?: Uri) {
return this.getSuggestionsFromConda();
super('CondaEnvService', serviceContainer);
}
// tslint:disable-next-line:no-empty
public dispose() { }
Expand Down Expand Up @@ -62,6 +63,9 @@ export class CondaEnvService implements IInterpreterLocatorService {
// tslint:disable-next-line:no-non-null-assertion
.then(interpreters => interpreters.map(interpreter => interpreter!));
}
protected getInterpretersImplementation(resource?: Uri): Promise<PythonInterpreter[]> {
return this.getSuggestionsFromConda();
}
private stripCompanyName(content: string) {
// Strip company name from version.
const startOfCompanyName = AnacondaCompanyNames.reduce((index, companyName) => {
Expand Down
4 changes: 2 additions & 2 deletions src/client/interpreter/locators/services/condaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ export class CondaService implements ICondaService {
const condaFile = await this.getCondaFile();
const envInfo = await this.processService.exec(condaFile, ['env', 'list']).then(output => output.stdout);
const environments = this.condaHelper.parseCondaEnvironmentNames(envInfo);
globalPersistence.value = { data: environments };
await globalPersistence.updateValue({ data: environments });
return environments;
} catch (ex) {
globalPersistence.value = { data: undefined };
await globalPersistence.updateValue({ data: undefined });
// Failed because either:
// 1. conda is not installed.
// 2. `conda env list has changed signature.
Expand Down
15 changes: 10 additions & 5 deletions src/client/interpreter/locators/services/currentPathService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ import * as path from 'path';
import { Uri } from 'vscode';
import { PythonSettings } from '../../../common/configSettings';
import { IProcessService } from '../../../common/process/types';
import { IInterpreterLocatorService, IInterpreterVersionService, InterpreterType } from '../../contracts';
import { IServiceContainer } from '../../../ioc/types';
import { IInterpreterVersionService, InterpreterType, PythonInterpreter } from '../../contracts';
import { IVirtualEnvironmentManager } from '../../virtualEnvs/types';
import { CacheableLocatorService } from './cacheableLocatorService';

@injectable()
export class CurrentPathService implements IInterpreterLocatorService {
export class CurrentPathService extends CacheableLocatorService {
public constructor( @inject(IVirtualEnvironmentManager) private virtualEnvMgr: IVirtualEnvironmentManager,
@inject(IInterpreterVersionService) private versionProvider: IInterpreterVersionService,
@inject(IProcessService) private processService: IProcessService) { }
public async getInterpreters(resource?: Uri) {
return this.suggestionsFromKnownPaths();
@inject(IProcessService) private processService: IProcessService,
@inject(IServiceContainer) serviceContainer: IServiceContainer) {
super('CurrentPathService', serviceContainer);
}
// tslint:disable-next-line:no-empty
public dispose() { }
protected getInterpretersImplementation(resource?: Uri): Promise<PythonInterpreter[]> {
return this.suggestionsFromKnownPaths();
}
private async suggestionsFromKnownPaths(resource?: Uri) {
const currentPythonInterpreter = this.getInterpreter(PythonSettings.getInstance(resource).pythonPath, '').then(interpreter => [interpreter]);
const python = this.getInterpreter('python', '').then(interpreter => [interpreter]);
Expand Down
15 changes: 10 additions & 5 deletions src/client/interpreter/locators/services/virtualEnvService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@ import * as _ from 'lodash';
import * as path from 'path';
import { Uri, workspace } from 'vscode';
import { fsReaddirAsync, IS_WINDOWS } from '../../../common/utils';
import { IInterpreterLocatorService, IInterpreterVersionService, IKnownSearchPathsForVirtualEnvironments, InterpreterType, PythonInterpreter } from '../../contracts';
import { IServiceContainer } from '../../../ioc/types';
import { IInterpreterVersionService, IKnownSearchPathsForVirtualEnvironments, InterpreterType, PythonInterpreter } from '../../contracts';
import { IVirtualEnvironmentManager } from '../../virtualEnvs/types';
import { lookForInterpretersInDirectory } from '../helpers';
import * as settings from './../../../common/configSettings';
import { CacheableLocatorService } from './cacheableLocatorService';

// tslint:disable-next-line:no-require-imports no-var-requires
const untildify = require('untildify');

@injectable()
export class VirtualEnvService implements IInterpreterLocatorService {
export class VirtualEnvService extends CacheableLocatorService {
public constructor( @inject(IKnownSearchPathsForVirtualEnvironments) private knownSearchPaths: string[],
@inject(IVirtualEnvironmentManager) private virtualEnvMgr: IVirtualEnvironmentManager,
@inject(IInterpreterVersionService) private versionProvider: IInterpreterVersionService) { }
public async getInterpreters(resource?: Uri) {
return this.suggestionsFromKnownVenvs();
@inject(IInterpreterVersionService) private versionProvider: IInterpreterVersionService,
@inject(IServiceContainer) serviceContainer: IServiceContainer) {
super('KnownPathsService', serviceContainer);
}
// tslint:disable-next-line:no-empty
public dispose() { }
protected getInterpretersImplementation(resource?: Uri): Promise<PythonInterpreter[]> {
return this.suggestionsFromKnownVenvs();
}
private async suggestionsFromKnownVenvs() {
return Promise.all(this.knownSearchPaths.map(dir => this.lookForInterpretersInVenvs(dir)))
// tslint:disable-next-line:underscore-consistent-invocation
Expand Down
Loading