forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontracts.ts
More file actions
152 lines (133 loc) · 6 KB
/
contracts.ts
File metadata and controls
152 lines (133 loc) · 6 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import { SemVer } from 'semver';
import { CodeLensProvider, ConfigurationTarget, Disposable, Event, TextDocument, Uri } from 'vscode';
import { InterpreterInfomation } from '../common/process/types';
import { Resource } from '../common/types';
export const INTERPRETER_LOCATOR_SERVICE = 'IInterpreterLocatorService';
export const WINDOWS_REGISTRY_SERVICE = 'WindowsRegistryService';
export const CONDA_ENV_FILE_SERVICE = 'CondaEnvFileService';
export const CONDA_ENV_SERVICE = 'CondaEnvService';
export const CURRENT_PATH_SERVICE = 'CurrentPathService';
export const KNOWN_PATH_SERVICE = 'KnownPathsService';
export const GLOBAL_VIRTUAL_ENV_SERVICE = 'VirtualEnvService';
export const WORKSPACE_VIRTUAL_ENV_SERVICE = 'WorkspaceVirtualEnvService';
export const PIPENV_SERVICE = 'PipEnvService';
export const IInterpreterVersionService = Symbol('IInterpreterVersionService');
export interface IInterpreterVersionService {
getVersion(pythonPath: string, defaultValue: string): Promise<string>;
getPipVersion(pythonPath: string): Promise<string>;
}
export const IKnownSearchPathsForInterpreters = Symbol('IKnownSearchPathsForInterpreters');
export interface IKnownSearchPathsForInterpreters {
getSearchPaths(): string[];
}
export const IVirtualEnvironmentsSearchPathProvider = Symbol('IVirtualEnvironmentsSearchPathProvider');
export interface IVirtualEnvironmentsSearchPathProvider {
getSearchPaths(resource?: Uri): Promise<string[]>;
}
export const IInterpreterLocatorService = Symbol('IInterpreterLocatorService');
export interface IInterpreterLocatorService extends Disposable {
readonly onLocating: Event<Promise<PythonInterpreter[]>>;
readonly hasInterpreters: Promise<boolean>;
getInterpreters(resource?: Uri, ignoreCache?: boolean): Promise<PythonInterpreter[]>;
}
export type CondaInfo = {
envs?: string[];
'sys.version'?: string;
'sys.prefix'?: string;
python_version?: string;
default_prefix?: string;
conda_version?: string;
};
export type CondaEnvironmentInfo = {
name: string;
path: string;
};
export const ICondaService = Symbol('ICondaService');
export interface ICondaService {
readonly condaEnvironmentsFile: string | undefined;
getCondaFile(): Promise<string>;
isCondaAvailable(): Promise<boolean>;
getCondaVersion(): Promise<SemVer | undefined>;
getCondaInfo(): Promise<CondaInfo | undefined>;
getCondaEnvironments(ignoreCache: boolean): Promise<CondaEnvironmentInfo[] | undefined>;
getInterpreterPath(condaEnvironmentPath: string): string;
getCondaFileFromInterpreter(interpreterPath?: string, envName?: string): Promise<string | undefined>;
isCondaEnvironment(interpreterPath: string): Promise<boolean>;
getCondaEnvironment(interpreterPath: string): Promise<CondaEnvironmentInfo | undefined>;
}
export enum InterpreterType {
Unknown = 'Unknown',
Conda = 'Conda',
VirtualEnv = 'VirtualEnv',
Pipenv = 'PipEnv',
Pyenv = 'Pyenv',
Venv = 'Venv',
WindowsStore = 'WindowsStore'
}
export type PythonInterpreter = InterpreterInfomation & {
companyDisplayName?: string;
displayName?: string;
type: InterpreterType;
envName?: string;
envPath?: string;
cachedEntry?: boolean;
};
export type WorkspacePythonPath = {
folderUri: Uri;
configTarget: ConfigurationTarget.Workspace | ConfigurationTarget.WorkspaceFolder;
};
export const IInterpreterService = Symbol('IInterpreterService');
export interface IInterpreterService {
onDidChangeInterpreter: Event<void>;
onDidChangeInterpreterInformation: Event<PythonInterpreter>;
hasInterpreters: Promise<boolean>;
getInterpreters(resource?: Uri): Promise<PythonInterpreter[]>;
getActiveInterpreter(resource?: Uri): Promise<PythonInterpreter | undefined>;
getInterpreterDetails(pythonPath: string, resoure?: Uri): Promise<undefined | PythonInterpreter>;
refresh(resource: Resource): Promise<void>;
initialize(): void;
getDisplayName(interpreter: Partial<PythonInterpreter>): Promise<string>;
}
export const IInterpreterDisplay = Symbol('IInterpreterDisplay');
export interface IInterpreterDisplay {
refresh(resource?: Uri): Promise<void>;
}
export const IShebangCodeLensProvider = Symbol('IShebangCodeLensProvider');
export interface IShebangCodeLensProvider extends CodeLensProvider {
detectShebang(document: TextDocument): Promise<string | undefined>;
}
export const IInterpreterHelper = Symbol('IInterpreterHelper');
export interface IInterpreterHelper {
getActiveWorkspaceUri(resource: Resource): WorkspacePythonPath | undefined;
getInterpreterInformation(pythonPath: string): Promise<undefined | Partial<PythonInterpreter>>;
isMacDefaultPythonPath(pythonPath: string): Boolean;
getInterpreterTypeDisplayName(interpreterType: InterpreterType): string | undefined;
getBestInterpreter(interpreters?: PythonInterpreter[]): PythonInterpreter | undefined;
}
export const IPipEnvService = Symbol('IPipEnvService');
export interface IPipEnvService {
executable: string;
isRelatedPipEnvironment(dir: string, pythonPath: string): Promise<boolean>;
}
export const IInterpreterLocatorHelper = Symbol('IInterpreterLocatorHelper');
export interface IInterpreterLocatorHelper {
mergeInterpreters(interpreters: PythonInterpreter[]): Promise<PythonInterpreter[]>;
}
export const IInterpreterWatcher = Symbol('IInterpreterWatcher');
export interface IInterpreterWatcher {
onDidCreate: Event<Resource>;
}
export const IInterpreterWatcherBuilder = Symbol('IInterpreterWatcherBuilder');
export interface IInterpreterWatcherBuilder {
getWorkspaceVirtualEnvInterpreterWatcher(resource: Resource): Promise<IInterpreterWatcher>;
}
export const IInterpreterLocatorProgressHandler = Symbol('IInterpreterLocatorProgressHandler');
export interface IInterpreterLocatorProgressHandler {
register(): void;
}
export const IInterpreterLocatorProgressService = Symbol('IInterpreterLocatorProgressService');
export interface IInterpreterLocatorProgressService {
readonly onRefreshing: Event<void>;
readonly onRefreshed: Event<void>;
register(): void;
}