-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathapi.ts
More file actions
1272 lines (1109 loc) · 39.3 KB
/
api.ts
File metadata and controls
1272 lines (1109 loc) · 39.3 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import {
Disposable,
Event,
FileChangeType,
LogOutputChannel,
MarkdownString,
TaskExecution,
Terminal,
TerminalOptions,
ThemeIcon,
Uri,
} from 'vscode';
/**
* The path to an icon, or a theme-specific configuration of icons.
*/
export type IconPath =
| Uri
| {
/**
* The icon path for the light theme.
*/
light: Uri;
/**
* The icon path for the dark theme.
*/
dark: Uri;
}
| ThemeIcon;
/**
* Options for executing a Python executable.
*/
export interface PythonCommandRunConfiguration {
/**
* Path to the binary like `python.exe` or `python3` to execute. This should be an absolute path
* to an executable that can be spawned.
*/
executable: string;
/**
* Arguments to pass to the python executable. These arguments will be passed on all execute calls.
* This is intended for cases where you might want to do interpreter specific flags.
*/
args?: string[];
}
/**
* Contains details on how to use a particular python environment
*
* Running In Terminal:
* 1. If {@link PythonEnvironmentExecutionInfo.activatedRun} is provided, then that will be used.
* 2. If {@link PythonEnvironmentExecutionInfo.activatedRun} is not provided, then:
* - If {@link PythonEnvironmentExecutionInfo.shellActivation} is provided and shell type is known, then that will be used.
* - If {@link PythonEnvironmentExecutionInfo.shellActivation} is provided and shell type is not known, then:
* - 'unknown' will be used if provided.
* - {@link PythonEnvironmentExecutionInfo.activation} will be used otherwise.
* - If {@link PythonEnvironmentExecutionInfo.shellActivation} is not provided, then {@link PythonEnvironmentExecutionInfo.activation} will be used.
* - If {@link PythonEnvironmentExecutionInfo.activation} is not provided, then {@link PythonEnvironmentExecutionInfo.run} will be used.
*
* Creating a Terminal:
* 1. If {@link PythonEnvironmentExecutionInfo.shellActivation} is provided and shell type is known, then that will be used.
* 2. If {@link PythonEnvironmentExecutionInfo.shellActivation} is provided and shell type is not known, then {@link PythonEnvironmentExecutionInfo.activation} will be used.
* 3. If {@link PythonEnvironmentExecutionInfo.shellActivation} is not provided, then:
* - 'unknown' will be used if provided.
* - {@link PythonEnvironmentExecutionInfo.activation} will be used otherwise.
* 4. If {@link PythonEnvironmentExecutionInfo.activation} is not provided, then {@link PythonEnvironmentExecutionInfo.run} will be used.
*
*/
export interface PythonEnvironmentExecutionInfo {
/**
* Details on how to run the python executable.
*/
run: PythonCommandRunConfiguration;
/**
* Details on how to run the python executable after activating the environment.
* If set this will overrides the {@link PythonEnvironmentExecutionInfo.run} command.
*/
activatedRun?: PythonCommandRunConfiguration;
/**
* Details on how to activate an environment.
*/
activation?: PythonCommandRunConfiguration[];
/**
* Details on how to activate an environment using a shell specific command.
* If set this will override the {@link PythonEnvironmentExecutionInfo.activation}.
* 'unknown' is used if shell type is not known.
* If 'unknown' is not provided and shell type is not known then
* {@link PythonEnvironmentExecutionInfo.activation} if set.
*/
shellActivation?: Map<string, PythonCommandRunConfiguration[]>;
/**
* Details on how to deactivate an environment.
*/
deactivation?: PythonCommandRunConfiguration[];
/**
* Details on how to deactivate an environment using a shell specific command.
* If set this will override the {@link PythonEnvironmentExecutionInfo.deactivation} property.
* 'unknown' is used if shell type is not known.
* If 'unknown' is not provided and shell type is not known then
* {@link PythonEnvironmentExecutionInfo.deactivation} if set.
*/
shellDeactivation?: Map<string, PythonCommandRunConfiguration[]>;
}
/**
* Interface representing the ID of a Python environment.
*/
export interface PythonEnvironmentId {
/**
* The unique identifier of the Python environment.
*/
id: string;
/**
* The ID of the manager responsible for the Python environment.
*/
managerId: string;
}
/**
* Display information for an environment group.
*/
export interface EnvironmentGroupInfo {
/**
* The name of the environment group. This is used as an identifier for the group.
*
* Note: The first instance of the group with the given name will be used in the UI.
*/
readonly name: string;
/**
* The description of the environment group.
*/
readonly description?: string;
/**
* The tooltip for the environment group, which can be a string or a Markdown string.
*/
readonly tooltip?: string | MarkdownString;
/**
* The icon path for the environment group, which can be a string, Uri, or an object with light and dark theme paths.
*/
readonly iconPath?: IconPath;
}
/**
* Interface representing information about a Python environment.
*/
export interface PythonEnvironmentInfo {
/**
* The name of the Python environment.
*/
readonly name: string;
/**
* The display name of the Python environment.
*/
readonly displayName: string;
/**
* The short display name of the Python environment.
*/
readonly shortDisplayName?: string;
/**
* The display path of the Python environment.
*/
readonly displayPath: string;
/**
* The version of the Python environment.
*/
readonly version: string;
/**
* Path to the python binary or environment folder.
*/
readonly environmentPath: Uri;
/**
* The description of the Python environment.
*/
readonly description?: string;
/**
* The tooltip for the Python environment, which can be a string or a Markdown string.
*/
readonly tooltip?: string | MarkdownString;
/**
* The icon path for the Python environment, which can be a string, Uri, or an object with light and dark theme paths.
*/
readonly iconPath?: IconPath;
/**
* Information on how to execute the Python environment. This is required for executing Python code in the environment.
*/
readonly execInfo: PythonEnvironmentExecutionInfo;
/**
* `sys.prefix` is the path to the base directory of the Python installation. Typically obtained by executing `sys.prefix` in the Python interpreter.
* This is required by extension like Jupyter, Pylance, and other extensions to provide better experience with python.
*/
readonly sysPrefix: string;
/**
* Optional `group` for this environment. This is used to group environments in the Environment Manager UI.
*/
readonly group?: string | EnvironmentGroupInfo;
/**
* Error message if the environment is broken or invalid.
* When set, indicates this environment has issues (e.g., broken symlinks, missing Python executable).
* The UI should display a warning indicator and show this message to help users diagnose and fix the issue.
*/
readonly error?: string;
}
/**
* Interface representing a Python environment.
*/
export interface PythonEnvironment extends PythonEnvironmentInfo {
/**
* The ID of the Python environment.
*/
readonly envId: PythonEnvironmentId;
}
/**
* Type representing the scope for setting a Python environment.
* Can be undefined or a URI.
*/
export type SetEnvironmentScope = undefined | Uri | Uri[];
/**
* Type representing the scope for getting a Python environment.
* Can be undefined or a URI.
*/
export type GetEnvironmentScope = undefined | Uri;
/**
* Type representing the scope for creating a Python environment.
* Can be a Python project or 'global'.
*/
export type CreateEnvironmentScope = Uri | Uri[] | 'global';
/**
* The scope for which environments are to be refreshed.
* - `undefined`: Search for environments globally and workspaces.
* - {@link Uri}: Environments in the workspace/folder or associated with the Uri.
*/
export type RefreshEnvironmentsScope = Uri | undefined;
/**
* The scope for which environments are required.
* - `"all"`: All environments.
* - `"global"`: Python installations that are usually a base for creating virtual environments.
* - {@link Uri}: Environments for the workspace/folder/file pointed to by the Uri.
*/
export type GetEnvironmentsScope = Uri | 'all' | 'global';
/**
* Event arguments for when the current Python environment changes.
*/
export type DidChangeEnvironmentEventArgs = {
/**
* The URI of the environment that changed.
*/
readonly uri: Uri | undefined;
/**
* The old Python environment before the change.
*/
readonly old: PythonEnvironment | undefined;
/**
* The new Python environment after the change.
*/
readonly new: PythonEnvironment | undefined;
};
/**
* Enum representing the kinds of environment changes.
*/
export enum EnvironmentChangeKind {
/**
* Indicates that an environment was added.
*/
add = 'add',
/**
* Indicates that an environment was removed.
*/
remove = 'remove',
}
/**
* Event arguments for when the list of Python environments changes.
*/
export type DidChangeEnvironmentsEventArgs = {
/**
* The kind of change that occurred (add or remove).
*/
kind: EnvironmentChangeKind;
/**
* The Python environment that was added or removed.
*/
environment: PythonEnvironment;
}[];
/**
* Type representing the context for resolving a Python environment.
*/
export type ResolveEnvironmentContext = Uri;
export interface QuickCreateConfig {
/**
* The description of the quick create step.
*/
readonly description: string;
/**
* The detail of the quick create step.
*/
readonly detail?: string;
}
/**
* Interface representing an environment manager.
*/
export interface EnvironmentManager {
/**
* The name of the environment manager. Allowed characters (a-z, A-Z, 0-9, -, _).
*/
readonly name: string;
/**
* The display name of the environment manager.
*/
readonly displayName?: string;
/**
* The preferred package manager ID for the environment manager. This is a combination
* of publisher id, extension id, and {@link EnvironmentManager.name package manager name}.
* `<publisher-id>.<extension-id>:<package-manager-name>`
*
* @example
* 'ms-python.python:pip'
*/
readonly preferredPackageManagerId: string;
/**
* The description of the environment manager.
*/
readonly description?: string;
/**
* The tooltip for the environment manager, which can be a string or a Markdown string.
*/
readonly tooltip?: string | MarkdownString | undefined;
/**
* The icon path for the environment manager, which can be a string, Uri, or an object with light and dark theme paths.
*/
readonly iconPath?: IconPath;
/**
* The log output channel for the environment manager.
*/
readonly log?: LogOutputChannel;
/**
* The quick create details for the environment manager. Having this method also enables the quick create feature
* for the environment manager. Should Implement {@link EnvironmentManager.create} to support quick create.
*/
quickCreateConfig?(): QuickCreateConfig | undefined;
/**
* Creates a new Python environment within the specified scope. Create should support adding a .gitignore file if it creates a folder within the workspace. If a manager does not support environment creation, do not implement this method; the UI disables "create" options when `this.manager.create === undefined`.
* @param scope - The scope within which to create the environment.
* @param options - Optional parameters for creating the Python environment.
* @returns A promise that resolves to the created Python environment, or undefined if creation failed.
*/
create?(scope: CreateEnvironmentScope, options?: CreateEnvironmentOptions): Promise<PythonEnvironment | undefined>;
/**
* Removes the specified Python environment.
* @param environment - The Python environment to remove.
* @returns A promise that resolves when the environment is removed.
*/
remove?(environment: PythonEnvironment): Promise<void>;
/**
* Refreshes the list of Python environments within the specified scope.
* @param scope - The scope within which to refresh environments.
* @returns A promise that resolves when the refresh is complete.
*/
refresh(scope: RefreshEnvironmentsScope): Promise<void>;
/**
* Retrieves a list of Python environments within the specified scope.
* @param scope - The scope within which to retrieve environments.
* @returns A promise that resolves to an array of Python environments.
*/
getEnvironments(scope: GetEnvironmentsScope): Promise<PythonEnvironment[]>;
/**
* Event that is fired when the list of Python environments changes.
*/
onDidChangeEnvironments?: Event<DidChangeEnvironmentsEventArgs>;
/**
* Sets the current Python environment within the specified scope.
* @param scope - The scope within which to set the environment.
* @param environment - The Python environment to set. If undefined, the environment is unset.
* @returns A promise that resolves when the environment is set.
*/
set(scope: SetEnvironmentScope, environment?: PythonEnvironment): Promise<void>;
/**
* Retrieves the current Python environment within the specified scope.
* @param scope - The scope within which to retrieve the environment.
* @returns A promise that resolves to the current Python environment, or undefined if none is set.
*/
get(scope: GetEnvironmentScope): Promise<PythonEnvironment | undefined>;
/**
* Event that is fired when the current Python environment changes.
*/
onDidChangeEnvironment?: Event<DidChangeEnvironmentEventArgs>;
/**
* Resolves the specified Python environment. The environment can be either a {@link PythonEnvironment} or a {@link Uri} context.
*
* This method is used to obtain a fully detailed {@link PythonEnvironment} object. The input can be:
* - A {@link PythonEnvironment} object, which might be missing key details such as {@link PythonEnvironment.execInfo}.
* - A {@link Uri} object, which typically represents either:
* - A folder that contains the Python environment.
* - The path to a Python executable.
*
* @param context - The context for resolving the environment, which can be a {@link PythonEnvironment} or a {@link Uri}.
* @returns A promise that resolves to the fully detailed {@link PythonEnvironment}, or `undefined` if the environment cannot be resolved.
*/
resolve(context: ResolveEnvironmentContext): Promise<PythonEnvironment | undefined>;
/**
* Clears the environment manager's cache.
*
* @returns A promise that resolves when the cache is cleared.
*/
clearCache?(): Promise<void>;
}
/**
* Interface representing a package ID.
*/
export interface PackageId {
/**
* The ID of the package.
*/
id: string;
/**
* The ID of the package manager.
*/
managerId: string;
/**
* The ID of the environment in which the package is installed.
*/
environmentId: string;
}
/**
* Interface representing package information.
*/
export interface PackageInfo {
/**
* The name of the package.
*/
readonly name: string;
/**
* The display name of the package.
*/
readonly displayName: string;
/**
* The version of the package.
*/
readonly version?: string;
/**
* The description of the package.
*/
readonly description?: string;
/**
* The tooltip for the package, which can be a string or a Markdown string.
*/
readonly tooltip?: string | MarkdownString | undefined;
/**
* The icon path for the package, which can be a string, Uri, or an object with light and dark theme paths.
*/
readonly iconPath?: IconPath;
/**
* The URIs associated with the package.
*/
readonly uris?: readonly Uri[];
}
/**
* Interface representing a package.
*/
export interface Package extends PackageInfo {
/**
* The ID of the package.
*/
readonly pkgId: PackageId;
}
/**
* Enum representing the kinds of package changes.
*/
export enum PackageChangeKind {
/**
* Indicates that a package was added.
*/
add = 'add',
/**
* Indicates that a package was removed.
*/
remove = 'remove',
}
/**
* Event arguments for when packages change.
*/
export interface DidChangePackagesEventArgs {
/**
* The Python environment in which the packages changed.
*/
environment: PythonEnvironment;
/**
* The package manager responsible for the changes.
*/
manager: PackageManager;
/**
* The list of changes, each containing the kind of change and the package affected.
*/
changes: { kind: PackageChangeKind; pkg: Package }[];
}
/**
* Interface representing a package manager.
*/
export interface PackageManager {
/**
* The name of the package manager. Allowed characters (a-z, A-Z, 0-9, -, _).
*/
name: string;
/**
* The display name of the package manager.
*/
displayName?: string;
/**
* The description of the package manager.
*/
description?: string;
/**
* The tooltip for the package manager, which can be a string or a Markdown string.
*/
tooltip?: string | MarkdownString | undefined;
/**
* The icon path for the package manager, which can be a string, Uri, or an object with light and dark theme paths.
*/
iconPath?: IconPath;
/**
* The log output channel for the package manager.
*/
log?: LogOutputChannel;
/**
* Installs/Uninstall packages in the specified Python environment.
* @param environment - The Python environment in which to install packages.
* @param options - Options for managing packages.
* @returns A promise that resolves when the installation is complete.
*/
manage(environment: PythonEnvironment, options: PackageManagementOptions): Promise<void>;
/**
* Refreshes the package list for the specified Python environment.
* @param environment - The Python environment for which to refresh the package list.
* @returns A promise that resolves when the refresh is complete.
*/
refresh(environment: PythonEnvironment): Promise<void>;
/**
* Retrieves the list of packages for the specified Python environment.
* @param environment - The Python environment for which to retrieve packages.
* @returns An array of packages, or undefined if the packages could not be retrieved.
*/
getPackages(environment: PythonEnvironment): Promise<Package[] | undefined>;
/**
* Event that is fired when packages change.
*/
onDidChangePackages?: Event<DidChangePackagesEventArgs>;
/**
* Clears the package manager's cache.
* @returns A promise that resolves when the cache is cleared.
*/
clearCache?(): Promise<void>;
}
/**
* Interface representing a Python project.
*/
export interface PythonProject {
/**
* The name of the Python project.
*/
readonly name: string;
/**
* The URI of the Python project.
*/
readonly uri: Uri;
/**
* The description of the Python project.
*/
readonly description?: string;
/**
* The tooltip for the Python project, which can be a string or a Markdown string.
*/
readonly tooltip?: string | MarkdownString;
}
/**
* Options for creating a Python project.
*/
export interface PythonProjectCreatorOptions {
/**
* The name of the Python project.
*/
name: string;
/**
* Path provided as the root for the project.
*/
rootUri: Uri;
/**
* Boolean indicating whether the project should be created without any user input.
*/
quickCreate?: boolean;
}
/**
* Interface representing a creator for Python projects.
*/
export interface PythonProjectCreator {
/**
* The name of the Python project creator.
*/
readonly name: string;
/**
* The display name of the Python project creator.
*/
readonly displayName?: string;
/**
* The description of the Python project creator.
*/
readonly description?: string;
/**
* The tooltip for the Python project creator, which can be a string or a Markdown string.
*/
readonly tooltip?: string | MarkdownString;
/**
* Creates a new Python project(s) or, if files are not a project, returns Uri(s) to the created files.
* Anything that needs its own python environment constitutes a project.
* @param options Optional parameters for creating the Python project.
* @returns A promise that resolves to one of the following:
* - PythonProject or PythonProject[]: when a single or multiple projects are created.
* - Uri or Uri[]: when files are created that do not constitute a project.
* - undefined: if project creation fails.
*/
create(options?: PythonProjectCreatorOptions): Promise<PythonProject | PythonProject[] | Uri | Uri[] | undefined>;
/**
* A flag indicating whether the project creator supports quick create where no user input is required.
*/
readonly supportsQuickCreate?: boolean;
}
/**
* Event arguments for when Python projects change.
*/
export interface DidChangePythonProjectsEventArgs {
/**
* The list of Python projects that were added.
*/
added: PythonProject[];
/**
* The list of Python projects that were removed.
*/
removed: PythonProject[];
}
export type PackageManagementOptions =
| {
/**
* Upgrade the packages if they are already installed.
*/
upgrade?: boolean;
/**
* Show option to skip package installation or uninstallation.
*/
showSkipOption?: boolean;
/**
* The list of packages to install.
*/
install: string[];
/**
* The list of packages to uninstall.
*/
uninstall?: string[];
}
| {
/**
* Upgrade the packages if they are already installed.
*/
upgrade?: boolean;
/**
* Show option to skip package installation or uninstallation.
*/
showSkipOption?: boolean;
/**
* The list of packages to install.
*/
install?: string[];
/**
* The list of packages to uninstall.
*/
uninstall: string[];
};
/**
* Options for creating a Python environment.
*/
export interface CreateEnvironmentOptions {
/**
* Provides some context about quick create based on user input.
* - if true, the environment should be created without any user input or prompts.
* - if false, the environment creation can show user input or prompts.
* This also means user explicitly skipped the quick create option.
* - if undefined, the environment creation can show user input or prompts.
* You can show quick create option to the user if you support it.
*/
quickCreate?: boolean;
/**
* Packages to install in addition to the automatically picked packages as a part of creating environment.
*/
additionalPackages?: string[];
}
/**
* Object representing the process started using run in background API.
*/
export interface PythonProcess {
/**
* The process ID of the Python process.
*/
readonly pid?: number;
/**
* The standard input of the Python process.
*/
readonly stdin: NodeJS.WritableStream;
/**
* The standard output of the Python process.
*/
readonly stdout: NodeJS.ReadableStream;
/**
* The standard error of the Python process.
*/
readonly stderr: NodeJS.ReadableStream;
/**
* Kills the Python process.
*/
kill(): void;
/**
* Event that is fired when the Python process exits.
*/
onExit(listener: (code: number | null, signal: NodeJS.Signals | null) => void): void;
}
export interface PythonEnvironmentManagerRegistrationApi {
/**
* Register an environment manager implementation.
*
* @param manager Environment Manager implementation to register.
* @returns A disposable that can be used to unregister the environment manager.
* @see {@link EnvironmentManager}
*/
registerEnvironmentManager(manager: EnvironmentManager): Disposable;
}
export interface PythonEnvironmentItemApi {
/**
* Create a Python environment item from the provided environment info. This item is used to interact
* with the environment.
*
* @param info Some details about the environment like name, version, etc. needed to interact with the environment.
* @param manager The environment manager to associate with the environment.
* @returns The Python environment.
*/
createPythonEnvironmentItem(info: PythonEnvironmentInfo, manager: EnvironmentManager): PythonEnvironment;
}
export interface PythonEnvironmentManagementApi {
/**
* Create a Python environment using environment manager associated with the scope.
*
* @param scope Where the environment is to be created.
* @param options Optional parameters for creating the Python environment.
* @returns The Python environment created. `undefined` if not created.
*/
createEnvironment(
scope: CreateEnvironmentScope,
options?: CreateEnvironmentOptions,
): Promise<PythonEnvironment | undefined>;
/**
* Remove a Python environment.
*
* @param environment The Python environment to remove.
* @returns A promise that resolves when the environment has been removed.
*/
removeEnvironment(environment: PythonEnvironment): Promise<void>;
}
export interface PythonEnvironmentsApi {
/**
* Initiates a refresh of Python environments within the specified scope.
* @param scope - The scope within which to search for environments.
* @returns A promise that resolves when the search is complete.
*/
refreshEnvironments(scope: RefreshEnvironmentsScope): Promise<void>;
/**
* Retrieves a list of Python environments within the specified scope.
* @param scope - The scope within which to retrieve environments.
* @returns A promise that resolves to an array of Python environments.
*/
getEnvironments(scope: GetEnvironmentsScope): Promise<PythonEnvironment[]>;
/**
* Event that is fired when the list of Python environments changes.
* @see {@link DidChangeEnvironmentsEventArgs}
*/
onDidChangeEnvironments: Event<DidChangeEnvironmentsEventArgs>;
/**
* This method is used to get the details missing from a PythonEnvironment. Like
* {@link PythonEnvironment.execInfo} and other details.
*
* @param context : The PythonEnvironment or Uri for which details are required.
*/
resolveEnvironment(context: ResolveEnvironmentContext): Promise<PythonEnvironment | undefined>;
}
export interface PythonProjectEnvironmentApi {
/**
* Sets the current Python environment within the specified scope.
* @param scope - The scope within which to set the environment.
* @param environment - The Python environment to set. If undefined, the environment is unset.
*/
setEnvironment(scope: SetEnvironmentScope, environment?: PythonEnvironment): Promise<void>;
/**
* Retrieves the current Python environment within the specified scope.
* @param scope - The scope within which to retrieve the environment.
* @returns A promise that resolves to the current Python environment, or undefined if none is set.
*/
getEnvironment(scope: GetEnvironmentScope): Promise<PythonEnvironment | undefined>;
/**
* Event that is fired when the selected Python environment changes for Project, Folder or File.
* @see {@link DidChangeEnvironmentEventArgs}
*/
onDidChangeEnvironment: Event<DidChangeEnvironmentEventArgs>;
}
export interface PythonEnvironmentManagerApi
extends
PythonEnvironmentManagerRegistrationApi,
PythonEnvironmentItemApi,
PythonEnvironmentManagementApi,
PythonEnvironmentsApi,
PythonProjectEnvironmentApi {}
export interface PythonPackageManagerRegistrationApi {
/**
* Register a package manager implementation.
*
* @param manager Package Manager implementation to register.
* @returns A disposable that can be used to unregister the package manager.
* @see {@link PackageManager}
*/
registerPackageManager(manager: PackageManager): Disposable;
}
export interface PythonPackageGetterApi {
/**
* Refresh the list of packages in a Python Environment.
*
* @param environment The Python Environment for which the list of packages is to be refreshed.
* @returns A promise that resolves when the list of packages has been refreshed.
*/
refreshPackages(environment: PythonEnvironment): Promise<void>;
/**
* Get the list of packages in a Python Environment.
*
* @param environment The Python Environment for which the list of packages is required.
* @returns The list of packages in the Python Environment.
*/
getPackages(environment: PythonEnvironment): Promise<Package[] | undefined>;
/**
* Event raised when the list of packages in a Python Environment changes.
* @see {@link DidChangePackagesEventArgs}
*/
onDidChangePackages: Event<DidChangePackagesEventArgs>;
}
export interface PythonPackageItemApi {
/**
* Create a package item from the provided package info.
*
* @param info The package info.
* @param environment The Python Environment in which the package is installed.
* @param manager The package manager that installed the package.
* @returns The package item.
*/
createPackageItem(info: PackageInfo, environment: PythonEnvironment, manager: PackageManager): Package;
}
export interface PythonPackageManagementApi {
/**
* Install/Uninstall packages into a Python Environment.
*
* @param environment The Python Environment into which packages are to be installed.
* @param packages The packages to install.
* @param options Options for installing packages.
*/
managePackages(environment: PythonEnvironment, options: PackageManagementOptions): Promise<void>;
}
export interface PythonPackageManagerApi
extends
PythonPackageManagerRegistrationApi,
PythonPackageGetterApi,