|
5 | 5 |
|
6 | 6 | import { Disposable, Event, Uri } from 'vscode';
|
7 | 7 | import { Resource } from './common/types';
|
8 |
| -import { Architecture } from './common/utils/platform'; |
9 | 8 | import { IDataViewerDataProvider, IJupyterUriProvider } from './jupyter/types';
|
10 | 9 | import { EnvPathType } from './pythonEnvironments/base/info';
|
11 | 10 | import {
|
| 11 | + EnvironmentDetails, |
| 12 | + EnvironmentDetailsOptions, |
| 13 | + EnvironmentProviderMetadata, |
12 | 14 | GetRefreshEnvironmentsOptions,
|
13 |
| - IPythonEnvsIterator, |
| 15 | + IEnvironmentProvider, |
14 | 16 | ProgressNotificationEvent,
|
15 | 17 | } from './pythonEnvironments/base/locator';
|
16 | 18 |
|
@@ -96,152 +98,6 @@ export interface IExtensionApi {
|
96 | 98 | };
|
97 | 99 | }
|
98 | 100 |
|
99 |
| -export interface EnvironmentDetailsOptions { |
100 |
| - useCache: boolean; |
101 |
| - /** |
102 |
| - * Return details provided by the specific provider, throws error if provider not found. |
103 |
| - */ |
104 |
| - providerId?: ProviderID; |
105 |
| -} |
106 |
| - |
107 |
| -type VersionInfo = { |
108 |
| - major: number; |
109 |
| - minor: number; |
110 |
| - micro: number; |
111 |
| - releaselevel: 'alpha' | 'beta' | 'candidate' | 'final'; |
112 |
| - serial: number; |
113 |
| -}; |
114 |
| - |
115 |
| -export interface EnvironmentDetails { |
116 |
| - executable: { |
117 |
| - path: string; |
118 |
| - bitness?: Architecture; |
119 |
| - sysPrefix: string; |
120 |
| - }; |
121 |
| - environment?: { |
122 |
| - type: EnvType; |
123 |
| - name?: string; |
124 |
| - path: string; |
125 |
| - project?: string; // Any specific project environment is created for. |
126 |
| - source: EnvSource[]; |
127 |
| - }; |
128 |
| - version: VersionInfo & { |
129 |
| - sysVersion?: string; |
130 |
| - }; |
131 |
| - implementation?: { |
132 |
| - // `sys.implementation` |
133 |
| - name: string; |
134 |
| - version: VersionInfo & { |
135 |
| - serial: number; |
136 |
| - }; |
137 |
| - }; |
138 |
| -} |
139 |
| - |
140 |
| -/** |
141 |
| - * Provider is only required to provide the `executable` key, rest are optional. So construct a type using |
142 |
| - * `EnvironmentDetails` where `executable` is the only required key. |
143 |
| - */ |
144 |
| -type EnvironmentDetailsByProvider = Partial<EnvironmentDetails> & Pick<EnvironmentDetails, 'executable'>; |
145 |
| - |
146 |
| -interface IEnvironmentProvider extends ILocatorFactoryAPI, IResolverAPI {} |
147 |
| - |
148 |
| -interface ILocatorFactoryAPI { |
149 |
| - /** |
150 |
| - * Factory function calling which create the locator. |
151 |
| - */ |
152 |
| - createLocator: ILocatorFactory; |
153 |
| -} |
154 |
| - |
155 |
| -interface IResolverAPI { |
156 |
| - /** |
157 |
| - * Returns true if provided environment is recognized by the provider. |
158 |
| - */ |
159 |
| - canIdentifyEnvironment: (env: BaseEnvInfo) => Promise<boolean>; |
160 |
| - /** |
161 |
| - * This is only called if this provider can identify the environment. |
162 |
| - * Returns details or `undefined` if it was found if env is invalid. |
163 |
| - */ |
164 |
| - getEnvironmentDetails: (env: BaseEnvInfo) => Promise<EnvironmentDetailsByProvider | undefined>; |
165 |
| -} |
166 |
| - |
167 |
| -export type ILocatorFactory = IWorkspaceLocatorFactory | INonWorkspaceLocatorFactory; |
168 |
| -export type INonWorkspaceLocatorFactory = () => ILocatorAPI; |
169 |
| -export type IWorkspaceLocatorFactory = (root: string) => ILocatorAPI; |
170 |
| - |
171 |
| -export interface ILocatorAPI { |
172 |
| - iterEnvs?(): IPythonEnvsIterator<EnvInfo>; |
173 |
| - readonly onChanged?: Event<LocatorEnvsChangedEvent>; |
174 |
| -} |
175 |
| - |
176 |
| -export type EnvInfo = BaseEnvInfo & { |
177 |
| - envSources: EnvSource[]; |
178 |
| -}; |
179 |
| - |
180 |
| -export type BaseEnvInfo = { |
181 |
| - executablePath: string; |
182 |
| - envPath?: string; |
183 |
| -}; |
184 |
| - |
185 |
| -type ProviderID = string; |
186 |
| - |
187 |
| -/** |
188 |
| - * These can be used when querying for a particular env. |
189 |
| - */ |
190 |
| -interface EnvironmentProviderMetadata { |
191 |
| - /** |
192 |
| - * Details about the environments the locator provides. |
193 |
| - * Useful when querying for a particular env. |
194 |
| - */ |
195 |
| - readonly environments?: EnvironmentMetaData; |
196 |
| - /** |
197 |
| - * If locator requires a workspace root to search envs within. |
198 |
| - */ |
199 |
| - readonly isWorkspaceBasedLocator: boolean; |
200 |
| - /** |
201 |
| - * An Identifier for the provider. |
202 |
| - */ |
203 |
| - readonly providerId: ProviderID; |
204 |
| -} |
205 |
| - |
206 |
| -interface EnvironmentMetaData { |
207 |
| - readonly envType: EnvType; |
208 |
| - readonly envSources: EnvSource[]; |
209 |
| -} |
210 |
| - |
211 |
| -export interface LocatorEnvsChangedEvent { |
212 |
| - /** |
213 |
| - * Any details known about the environment which can be used for query. |
214 |
| - */ |
215 |
| - env?: EnvironmentMetaData; |
216 |
| - /** |
217 |
| - * Details about how the environment was modified. |
218 |
| - * */ |
219 |
| - type: EnvChangeType; |
220 |
| -} |
221 |
| - |
222 |
| -export type EnvChangeType = 'add' | 'remove' | 'update'; |
223 |
| - |
224 |
| -export type EnvType = KnownEnvTypes | string; |
225 |
| - |
226 |
| -export enum KnownEnvTypes { |
227 |
| - VirtualEnv = 'VirtualEnv', |
228 |
| - Conda = 'Conda', |
229 |
| - Unknown = 'Unknown', |
230 |
| - Global = 'Global', |
231 |
| -} |
232 |
| - |
233 |
| -export type EnvSource = KnownEnvSourceTypes | string; |
234 |
| - |
235 |
| -export enum KnownEnvSourceTypes { |
236 |
| - Conda = 'Conda', |
237 |
| - Pipenv = 'PipEnv', |
238 |
| - Poetry = 'Poetry', |
239 |
| - VirtualEnv = 'VirtualEnv', |
240 |
| - Venv = 'Venv', |
241 |
| - VirtualEnvWrapper = 'VirtualEnvWrapper', |
242 |
| - Pyenv = 'Pyenv', |
243 |
| -} |
244 |
| - |
245 | 101 | export interface EnvironmentsChangedParams {
|
246 | 102 | /**
|
247 | 103 | * Path to environment folder or path to interpreter that uniquely identifies an environment.
|
|
0 commit comments