@@ -14,6 +14,62 @@ import {
14
14
PythonEnvsWatcher ,
15
15
} from './watcher' ;
16
16
17
+ export interface ILocatorClass {
18
+ new ( root ?: string ) : ILocatorAPI ;
19
+ }
20
+
21
+ export interface ILocatorAPI {
22
+ iterEnvs ?( ) : IPythonEnvsIterator < EnvInfo > ;
23
+ readonly onChanged ?: Event < LocatorEnvsChangedEvent > ;
24
+ }
25
+
26
+ export type EnvInfo = {
27
+ envSources : EnvSource [ ] ;
28
+ executablePath : string ;
29
+ envPath ?: string ;
30
+ } ;
31
+
32
+ /**
33
+ * These can be used when querying for a particular env.
34
+ */
35
+ interface EnvironmentProviderMetadata {
36
+ readonly envType : EnvType ;
37
+ readonly searchLocation ?: string ;
38
+ readonly envSources : EnvSource [ ] ;
39
+ readonly isRootBasedLocator : boolean ;
40
+ }
41
+
42
+ type EnvironmentMetaData = EnvironmentProviderMetadata ;
43
+
44
+ export interface LocatorEnvsChangedEvent {
45
+ /**
46
+ * Any details known about the environment which can be used for query.
47
+ */
48
+ env ?: EnvironmentMetaData ;
49
+ type : EnvChangeType ;
50
+ }
51
+
52
+ export type EnvChangeType = 'add' | 'remove' | 'update' ;
53
+
54
+ export enum EnvType {
55
+ VirtualEnv = 'VirtualEnv' ,
56
+ Conda = 'Conda' ,
57
+ Unknown = 'Unknown' ,
58
+ Global = 'GlobalInterpreter' ,
59
+ }
60
+
61
+ export enum EnvSource {
62
+ Conda = 'Conda' ,
63
+ Pipenv = 'PipEnv' ,
64
+ Poetry = 'Poetry' ,
65
+ VirtualEnv = 'VirtualEnv' ,
66
+ Venv = 'Venv' ,
67
+ VirtualEnvWrapper = 'VirtualEnvWrapper' ,
68
+ WindowsStore = 'WindowsStore' ,
69
+ Pyenv = 'Pyenv' ,
70
+ Custom = 'Custom' ,
71
+ }
72
+
17
73
/**
18
74
* A single update to a previously provided Python env object.
19
75
*/
@@ -153,7 +209,9 @@ export type BasicEnvInfo = {
153
209
* events emitted via `onChanged` do not need to provide information
154
210
* for the specific environments that changed.
155
211
*/
156
- export interface ILocator < I = PythonEnvInfo , E = PythonEnvsChangedEvent > extends IPythonEnvsWatcher < E > {
212
+ export interface ILocator < I = PythonEnvInfo , E extends BasicPythonEnvsChangedEvent = PythonEnvsChangedEvent >
213
+ extends IPythonEnvsWatcher < E > ,
214
+ IEnvProvider {
157
215
/**
158
216
* Iterate over the enviroments known tos this locator.
159
217
*
@@ -173,6 +231,10 @@ export interface ILocator<I = PythonEnvInfo, E = PythonEnvsChangedEvent> extends
173
231
iterEnvs ( query ?: QueryForEvent < E > ) : IPythonEnvsIterator < I > ;
174
232
}
175
233
234
+ export interface IEnvProvider {
235
+ addNewLocator ?( LocatorClass : ILocatorClass , isWorkspace : boolean ) : void ;
236
+ }
237
+
176
238
interface IResolver {
177
239
/**
178
240
* Find as much info about the given Python environment as possible.
@@ -203,7 +265,7 @@ export type TriggerRefreshOptions = {
203
265
ifNotTriggerredAlready ?: boolean ;
204
266
} ;
205
267
206
- export interface IDiscoveryAPI {
268
+ export interface IDiscoveryAPI extends IEnvProvider {
207
269
/**
208
270
* Tracks discovery progress for current list of known environments, i.e when it starts, finishes or any other relevant
209
271
* stage. Note the progress for a particular query is currently not tracked or reported, this only indicates progress of
0 commit comments