@@ -143,10 +143,10 @@ export interface EnvironmentDetails {
143
143
path : string ;
144
144
project ?: string ; // Any specific project environment is created for.
145
145
source : EnvSource [ ] ;
146
- } ; ;
146
+ } ;
147
147
version : VersionInfo & {
148
148
sysVersion ?: string ;
149
- } ; ;
149
+ } ;
150
150
implementation ?: {
151
151
// `sys.implementation`
152
152
name : string ;
@@ -156,6 +156,92 @@ export interface EnvironmentDetails {
156
156
} ;
157
157
}
158
158
159
+ /**
160
+ * Provider is only required to provide the `executable` key, rest are optional. So construct a type using
161
+ * `EnvironmentDetails` where `executable` is the only required key.
162
+ */
163
+ type EnvironmentDetailsByProvider = Partial < EnvironmentDetails > & Pick < EnvironmentDetails , 'executable' > ;
164
+
165
+ interface IEnvironmentProvider {
166
+ createLocator : ILocatorFactory ;
167
+ getEnvironmentDetails : ( env : EnvInfo ) => Promise < EnvironmentDetailsByProvider | undefined > ;
168
+ }
169
+
170
+ export type ILocatorFactory = INonWorkspaceLocatorFactory | IWorkspaceLocatorFactory ;
171
+ export type INonWorkspaceLocatorFactory = ( ) => ILocatorAPI ;
172
+ export type IWorkspaceLocatorFactory = ( root : string ) => ILocatorAPI ;
173
+
174
+ export interface ILocatorAPI {
175
+ iterEnvs ?( ) : IPythonEnvsIterator < EnvInfo > ;
176
+ readonly onChanged ?: Event < LocatorEnvsChangedEvent > ;
177
+ }
178
+
179
+ export type EnvInfo = {
180
+ envSources : EnvSource [ ] ;
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
+
159
245
export interface EnvironmentsChangedParams {
160
246
/**
161
247
* Path to environment folder or path to interpreter that uniquely identifies an environment.
@@ -263,89 +349,3 @@ export interface IProposedExtensionAPI {
263
349
) : Promise < Disposable > ; // TODO: Disposable?? // TODO: Confirm whether this should return a promise??
264
350
} ;
265
351
}
266
-
267
- /**
268
- * Provider is only expected to provide the executable key, so construct a type using `EnvironmentDetails`
269
- * where `executable` is the only necessary key.
270
- */
271
- type EnvironmentDetailsByProvider = Omit < Partial < EnvironmentDetails > , 'executable' > &
272
- Pick < EnvironmentDetails , 'executable' > ;
273
-
274
- interface IEnvironmentProvider {
275
- createLocator : ILocatorFactory ;
276
- getEnvironmentDetails : ( env : EnvInfo ) => Promise < EnvironmentDetailsByProvider | undefined > ;
277
- }
278
-
279
- type isRootBasedLocatorFactory = ( ( root : string ) => ILocatorAPI ) ;
280
- export type ILocatorFactory = ( ( ) => ILocatorAPI ) | isRootBasedLocatorFactory ;
281
-
282
- export interface ILocatorAPI {
283
- iterEnvs ?( ) : IPythonEnvsIterator < EnvInfo > ;
284
- readonly onChanged ?: Event < LocatorEnvsChangedEvent > ;
285
- }
286
-
287
- export type EnvInfo = {
288
- envSources : EnvSource [ ] ;
289
- executablePath : string ;
290
- envPath ?: string ;
291
- } ;
292
-
293
- type ProviderID = string ;
294
-
295
- /**
296
- * These can be used when querying for a particular env.
297
- */
298
- interface EnvironmentProviderMetadata {
299
- /**
300
- * Details about the environments the locator provides.
301
- * Useful when querying for a particular env.
302
- */
303
- readonly environments ?: EnvironmentMetaData ;
304
- /**
305
- * If locator requires a root to search envs within.
306
- */
307
- readonly isRootBasedLocator : boolean ;
308
- /**
309
- * An Identifier for the provider.
310
- */
311
- readonly providerId : ProviderID ;
312
- }
313
-
314
- interface EnvironmentMetaData {
315
- readonly envType : EnvType ;
316
- readonly envSources : EnvSource [ ] ;
317
- }
318
-
319
- export interface LocatorEnvsChangedEvent {
320
- /**
321
- * Any details known about the environment which can be used for query.
322
- */
323
- env ?: EnvironmentMetaData ;
324
- /**
325
- * Details about how the environment was modified.
326
- **/
327
- type : EnvChangeType ;
328
- }
329
-
330
- export type EnvChangeType = 'add' | 'remove' | 'update' ;
331
-
332
- export type EnvType = KnownEnvTypes | string ;
333
-
334
- export enum KnownEnvTypes {
335
- VirtualEnv = 'VirtualEnv' ,
336
- Conda = 'Conda' ,
337
- Unknown = 'Unknown' ,
338
- Global = 'Global' ,
339
- }
340
-
341
- export type EnvSource = KnownEnvSourceTypes | string ;
342
-
343
- export enum KnownEnvSourceTypes {
344
- Conda = 'Conda' ,
345
- Pipenv = 'PipEnv' ,
346
- Poetry = 'Poetry' ,
347
- VirtualEnv = 'VirtualEnv' ,
348
- Venv = 'Venv' ,
349
- VirtualEnvWrapper = 'VirtualEnvWrapper' ,
350
- Pyenv = 'Pyenv' ,
351
- }
0 commit comments