6
6
7
7
import { inject , injectable , named } from 'inversify' ;
8
8
import { dirname } from 'path' ;
9
- import { CancellationToken , Event , Extension , Memento , Uri } from 'vscode' ;
9
+ import { Extension , Memento , Uri } from 'vscode' ;
10
10
import type { SemVer } from 'semver' ;
11
11
import { IContextKeyManager , IWorkspaceService } from '../common/application/types' ;
12
12
import { JUPYTER_EXTENSION_ID , PYLANCE_EXTENSION_ID } from '../common/constants' ;
13
- import { InterpreterUri , ModuleInstallFlags } from '../common/installer/types' ;
14
- import {
15
- GLOBAL_MEMENTO ,
16
- IExtensions ,
17
- IInstaller ,
18
- IMemento ,
19
- InstallerResponse ,
20
- Product ,
21
- ProductInstallStatus ,
22
- Resource ,
23
- } from '../common/types' ;
13
+ import { GLOBAL_MEMENTO , IExtensions , IMemento , Resource } from '../common/types' ;
24
14
import { getDebugpyPackagePath } from '../debugger/extension/adapter/remoteLaunchers' ;
25
15
import { IEnvironmentActivationService } from '../interpreter/activation/types' ;
26
16
import { IInterpreterQuickPickItem , IInterpreterSelector } from '../interpreter/configuration/types' ;
27
- import {
28
- IComponentAdapter ,
29
- ICondaService ,
30
- IInterpreterDisplay ,
31
- IInterpreterService ,
32
- IInterpreterStatusbarVisibilityFilter ,
33
- PythonEnvironmentsChangedEvent ,
34
- } from '../interpreter/contracts' ;
17
+ import { ICondaService , IInterpreterDisplay , IInterpreterStatusbarVisibilityFilter } from '../interpreter/contracts' ;
35
18
import { PythonEnvironment } from '../pythonEnvironments/info' ;
36
19
import { PylanceApi } from '../activation/node/pylanceApi' ;
37
20
import { ExtensionContextKey } from '../common/application/contextKeys' ;
38
- /**
39
- * This allows Python extension to update Product enum without breaking Jupyter.
40
- * I.e. we have a strict contract, else using numbers (in enums) is bound to break across products.
41
- */
42
- enum JupyterProductToInstall {
43
- jupyter = 'jupyter' ,
44
- ipykernel = 'ipykernel' ,
45
- notebook = 'notebook' ,
46
- kernelspec = 'kernelspec' ,
47
- nbconvert = 'nbconvert' ,
48
- pandas = 'pandas' ,
49
- pip = 'pip' ,
50
- }
51
-
52
- const ProductMapping : { [ key in JupyterProductToInstall ] : Product } = {
53
- [ JupyterProductToInstall . ipykernel ] : Product . ipykernel ,
54
- [ JupyterProductToInstall . jupyter ] : Product . jupyter ,
55
- [ JupyterProductToInstall . kernelspec ] : Product . kernelspec ,
56
- [ JupyterProductToInstall . nbconvert ] : Product . nbconvert ,
57
- [ JupyterProductToInstall . notebook ] : Product . notebook ,
58
- [ JupyterProductToInstall . pandas ] : Product . pandas ,
59
- [ JupyterProductToInstall . pip ] : Product . pip ,
60
- } ;
61
21
62
22
type PythonApiForJupyterExtension = {
63
- /**
64
- * IInterpreterService
65
- */
66
- onDidChangeInterpreter : Event < Uri | undefined > ;
67
- /**
68
- * IInterpreterService
69
- */
70
- readonly refreshPromise : Promise < void > | undefined ;
71
- /**
72
- * IInterpreterService
73
- */
74
- readonly onDidChangeInterpreters : Event < PythonEnvironmentsChangedEvent > ;
75
- /**
76
- * Equivalent to getInterpreters() in IInterpreterService
77
- */
78
- getKnownInterpreters ( resource ?: Uri ) : PythonEnvironment [ ] ;
79
- /**
80
- * @deprecated Use `getKnownInterpreters`, `onDidChangeInterpreters`, and `refreshPromise` instead.
81
- * Equivalent to getAllInterpreters() in IInterpreterService
82
- */
83
- getInterpreters ( resource ?: Uri ) : Promise < PythonEnvironment [ ] > ;
84
- /**
85
- * IInterpreterService
86
- */
87
- getActiveInterpreter ( resource ?: Uri ) : Promise < PythonEnvironment | undefined > ;
88
- /**
89
- * IInterpreterService
90
- */
91
- getInterpreterDetails ( pythonPath : string , resource ?: Uri ) : Promise < undefined | PythonEnvironment > ;
92
-
93
23
/**
94
24
* IEnvironmentActivationService
95
25
*/
@@ -98,31 +28,11 @@ type PythonApiForJupyterExtension = {
98
28
interpreter ?: PythonEnvironment ,
99
29
allowExceptions ?: boolean ,
100
30
) : Promise < NodeJS . ProcessEnv | undefined > ;
101
- isMicrosoftStoreInterpreter ( pythonPath : string ) : Promise < boolean > ;
102
- suggestionToQuickPickItem ( suggestion : PythonEnvironment , workspaceUri ?: Uri | undefined ) : IInterpreterQuickPickItem ;
103
31
getKnownSuggestions ( resource : Resource ) : IInterpreterQuickPickItem [ ] ;
104
32
/**
105
33
* @deprecated Use `getKnownSuggestions` and `suggestionToQuickPickItem` instead.
106
34
*/
107
35
getSuggestions ( resource : Resource ) : Promise < IInterpreterQuickPickItem [ ] > ;
108
- /**
109
- * IInstaller
110
- */
111
- install (
112
- product : JupyterProductToInstall ,
113
- resource ?: InterpreterUri ,
114
- cancel ?: CancellationToken ,
115
- reInstallAndUpdate ?: boolean ,
116
- installPipIfRequired ?: boolean ,
117
- ) : Promise < InstallerResponse > ;
118
- /**
119
- * IInstaller
120
- */
121
- isProductVersionCompatible (
122
- product : Product ,
123
- semVerRequirement : string ,
124
- resource ?: InterpreterUri ,
125
- ) : Promise < ProductInstallStatus > ;
126
36
/**
127
37
* Returns path to where `debugpy` is. In python extension this is `/pythonFiles/lib/python`.
128
38
*/
@@ -140,10 +50,6 @@ type PythonApiForJupyterExtension = {
140
50
* Returns the conda executable.
141
51
*/
142
52
getCondaFile ( ) : Promise < string | undefined > ;
143
- getEnvironmentActivationShellCommands (
144
- resource : Resource ,
145
- interpreter ?: PythonEnvironment ,
146
- ) : Promise < string [ ] | undefined > ;
147
53
148
54
/**
149
55
* Call to provide a function that the Python extension can call to request the Python
@@ -181,13 +87,10 @@ export class JupyterExtensionIntegration {
181
87
182
88
constructor (
183
89
@inject ( IExtensions ) private readonly extensions : IExtensions ,
184
- @inject ( IInterpreterService ) private readonly interpreterService : IInterpreterService ,
185
90
@inject ( IInterpreterSelector ) private readonly interpreterSelector : IInterpreterSelector ,
186
- @inject ( IInstaller ) private readonly installer : IInstaller ,
187
91
@inject ( IEnvironmentActivationService ) private readonly envActivation : IEnvironmentActivationService ,
188
92
@inject ( IMemento ) @named ( GLOBAL_MEMENTO ) private globalState : Memento ,
189
93
@inject ( IInterpreterDisplay ) private interpreterDisplay : IInterpreterDisplay ,
190
- @inject ( IComponentAdapter ) private pyenvs : IComponentAdapter ,
191
94
@inject ( IWorkspaceService ) private workspaceService : IWorkspaceService ,
192
95
@inject ( ICondaService ) private readonly condaService : ICondaService ,
193
96
@inject ( IContextKeyManager ) private readonly contextManager : IContextKeyManager ,
@@ -201,54 +104,15 @@ export class JupyterExtensionIntegration {
201
104
}
202
105
// Forward python parts
203
106
jupyterExtensionApi . registerPythonApi ( {
204
- onDidChangeInterpreter : this . interpreterService . onDidChangeInterpreter ,
205
- getActiveInterpreter : async ( resource ?: Uri ) => this . interpreterService . getActiveInterpreter ( resource ) ,
206
- getInterpreterDetails : async ( pythonPath : string ) =>
207
- this . interpreterService . getInterpreterDetails ( pythonPath ) ,
208
- refreshPromise : this . interpreterService . refreshPromise ,
209
- onDidChangeInterpreters : this . interpreterService . onDidChangeInterpreters ,
210
- getKnownInterpreters : ( resource : Uri | undefined ) => this . pyenvs . getInterpreters ( resource ) ,
211
- getInterpreters : async ( resource : Uri | undefined ) => this . interpreterService . getAllInterpreters ( resource ) ,
212
107
getActivatedEnvironmentVariables : async (
213
108
resource : Resource ,
214
109
interpreter ?: PythonEnvironment ,
215
110
allowExceptions ?: boolean ,
216
111
) => this . envActivation . getActivatedEnvironmentVariables ( resource , interpreter , allowExceptions ) ,
217
- isMicrosoftStoreInterpreter : async ( pythonPath : string ) : Promise < boolean > =>
218
- this . pyenvs . isMicrosoftStoreInterpreter ( pythonPath ) ,
219
112
getSuggestions : async ( resource : Resource ) : Promise < IInterpreterQuickPickItem [ ] > =>
220
113
this . interpreterSelector . getAllSuggestions ( resource ) ,
221
114
getKnownSuggestions : ( resource : Resource ) : IInterpreterQuickPickItem [ ] =>
222
115
this . interpreterSelector . getSuggestions ( resource ) ,
223
- suggestionToQuickPickItem : (
224
- suggestion : PythonEnvironment ,
225
- workspaceUri ?: Uri | undefined ,
226
- ) : IInterpreterQuickPickItem =>
227
- this . interpreterSelector . suggestionToQuickPickItem ( suggestion , workspaceUri ) ,
228
- install : async (
229
- product : JupyterProductToInstall ,
230
- resource ?: InterpreterUri ,
231
- cancel ?: CancellationToken ,
232
- reInstallAndUpdate ?: boolean ,
233
- installPipIfRequired ?: boolean ,
234
- ) : Promise < InstallerResponse > => {
235
- let flags =
236
- reInstallAndUpdate === true
237
- ? ModuleInstallFlags . updateDependencies | ModuleInstallFlags . reInstall
238
- : undefined ;
239
- if ( installPipIfRequired === true ) {
240
- flags = flags
241
- ? flags | ModuleInstallFlags . installPipIfRequired
242
- : ModuleInstallFlags . installPipIfRequired ;
243
- }
244
- return this . installer . install ( ProductMapping [ product ] , resource , cancel , flags ) ;
245
- } ,
246
- isProductVersionCompatible : async (
247
- product : Product ,
248
- semVerRequirement : string ,
249
- resource ?: InterpreterUri ,
250
- ) : Promise < ProductInstallStatus > =>
251
- this . installer . isProductVersionCompatible ( product , semVerRequirement , resource ) ,
252
116
getDebuggerPath : async ( ) => dirname ( getDebugpyPackagePath ( ) ) ,
253
117
getInterpreterPathSelectedForJupyterServer : ( ) =>
254
118
this . globalState . get < string | undefined > ( 'INTERPRETER_PATH_SELECTED_FOR_JUPYTER_SERVER' ) ,
@@ -257,8 +121,6 @@ export class JupyterExtensionIntegration {
257
121
) ,
258
122
getCondaFile : ( ) => this . condaService . getCondaFile ( ) ,
259
123
getCondaVersion : ( ) => this . condaService . getCondaVersion ( ) ,
260
- getEnvironmentActivationShellCommands : ( resource : Resource , interpreter ?: PythonEnvironment ) =>
261
- this . envActivation . getEnvironmentActivationShellCommands ( resource , interpreter ) ,
262
124
registerJupyterPythonPathFunction : ( func : ( uri : Uri ) => Promise < string | undefined > ) =>
263
125
this . registerJupyterPythonPathFunction ( func ) ,
264
126
registerGetNotebookUriForTextDocumentUriFunction : ( func : ( textDocumentUri : Uri ) => Uri | undefined ) =>
0 commit comments