@@ -5,6 +5,10 @@ import * as path from 'path';
5
5
import { EXTENSION_ROOT_DIR } from '../constants' ;
6
6
import { PythonVersionInfo } from './types' ;
7
7
8
+ // It is simpler to hard-code the extension root dir than to use vscode.ExtensionContext.extensionPath.
9
+ const SCRIPTS_DIR = path . join ( EXTENSION_ROOT_DIR , 'pythonFiles' ) ;
10
+ const ISOLATED = path . join ( SCRIPTS_DIR , 'pyvsc-run-isolated.py' ) ;
11
+
8
12
/****************************
9
13
* The following namespaces cover the following:
10
14
*
@@ -40,9 +44,6 @@ import { PythonVersionInfo } from './types';
40
44
// * install_debugpy.py (used only for extension development)
41
45
// * ptvsd_launcher.py (used only for the old debug adapter)
42
46
export namespace scripts {
43
- // It is simpler to hard-code it instead of using vscode.ExtensionContext.extensionPath.
44
- const SCRIPTS_DIR = path . join ( EXTENSION_ROOT_DIR , 'pythonFiles' ) ;
45
-
46
47
//============================
47
48
// interpreterInfo.py
48
49
@@ -55,7 +56,7 @@ export namespace scripts {
55
56
56
57
export function interpreterInfo ( ) : [ string [ ] , ( out : string ) => PythonEnvInfo ] {
57
58
const script = path . join ( SCRIPTS_DIR , 'interpreterInfo.py' ) ;
58
- const args = [ script ] ;
59
+ const args = [ ISOLATED , script ] ;
59
60
60
61
function parse ( out : string ) : PythonEnvInfo {
61
62
let json : PythonEnvInfo ;
@@ -165,7 +166,7 @@ export namespace scripts {
165
166
166
167
export function completion ( jediPath ?: string ) : [ string [ ] , ( out : string ) => _completion . Response [ ] ] {
167
168
const script = path . join ( SCRIPTS_DIR , 'completion.py' ) ;
168
- const args = [ script ] ;
169
+ const args = [ ISOLATED , script ] ;
169
170
if ( jediPath ) {
170
171
args . push ( 'custom' ) ;
171
172
args . push ( jediPath ) ;
@@ -183,7 +184,7 @@ export namespace scripts {
183
184
184
185
export function sortImports ( filename : string , sortArgs ?: string [ ] ) : [ string [ ] , ( out : string ) => string ] {
185
186
const script = path . join ( SCRIPTS_DIR , 'sortImports.py' ) ;
186
- const args = [ script , filename , '--diff' ] ;
187
+ const args = [ ISOLATED , script , filename , '--diff' ] ;
187
188
if ( sortArgs ) {
188
189
args . push ( ...sortArgs ) ;
189
190
}
@@ -201,7 +202,7 @@ export namespace scripts {
201
202
202
203
export function refactor ( root : string ) : [ string [ ] , ( out : string ) => object [ ] ] {
203
204
const script = path . join ( SCRIPTS_DIR , 'refactor.py' ) ;
204
- const args = [ script , root ] ;
205
+ const args = [ ISOLATED , script , root ] ;
205
206
206
207
// tslint:disable-next-line:no-suspicious-comment
207
208
// TODO: Make the return type more specific, like we did
@@ -223,7 +224,7 @@ export namespace scripts {
223
224
224
225
export function normalizeForInterpreter ( code : string ) : [ string [ ] , ( out : string ) => string ] {
225
226
const script = path . join ( SCRIPTS_DIR , 'normalizeForInterpreter.py' ) ;
226
- const args = [ script , code ] ;
227
+ const args = [ ISOLATED , script , code ] ;
227
228
228
229
function parse ( out : string ) {
229
230
// The text will be used as-is.
@@ -262,7 +263,7 @@ export namespace scripts {
262
263
text ?: string
263
264
) : [ string [ ] , ( out : string ) => _symbolProvider . Symbols ] {
264
265
const script = path . join ( SCRIPTS_DIR , 'symbolProvider.py' ) ;
265
- const args = [ script , filename ] ;
266
+ const args = [ ISOLATED , script , filename ] ;
266
267
if ( text ) {
267
268
args . push ( text ) ;
268
269
}
@@ -279,7 +280,7 @@ export namespace scripts {
279
280
280
281
export function printEnvVariables ( ) : [ string [ ] , ( out : string ) => NodeJS . ProcessEnv ] {
281
282
const script = path . join ( SCRIPTS_DIR , 'printEnvVariables.py' ) . fileToCommandArgument ( ) ;
282
- const args = [ script ] ;
283
+ const args = [ ISOLATED , script ] ;
283
284
284
285
function parse ( out : string ) : NodeJS . ProcessEnv {
285
286
return JSON . parse ( out ) ;
@@ -293,7 +294,7 @@ export namespace scripts {
293
294
294
295
export function printEnvVariablesToFile ( filename : string ) : [ string [ ] , ( out : string ) => NodeJS . ProcessEnv ] {
295
296
const script = path . join ( SCRIPTS_DIR , 'printEnvVariablesToFile.py' ) ;
296
- const args = [ script , filename . fileToCommandArgument ( ) ] ;
297
+ const args = [ ISOLATED , script , filename . fileToCommandArgument ( ) ] ;
297
298
298
299
function parse ( out : string ) : NodeJS . ProcessEnv {
299
300
return JSON . parse ( out ) ;
@@ -310,6 +311,7 @@ export namespace scripts {
310
311
// We don't bother with a "parse" function since the output
311
312
// could be anything.
312
313
return [
314
+ ISOLATED ,
313
315
script ,
314
316
command . fileToCommandArgument ( ) ,
315
317
// The shell args must come after the command
@@ -325,7 +327,7 @@ export namespace scripts {
325
327
export function testlauncher ( testArgs : string [ ] ) : string [ ] {
326
328
const script = path . join ( SCRIPTS_DIR , 'testlauncher.py' ) ;
327
329
// There is no output to parse, so we do not return a function.
328
- return [ script , ...testArgs ] ;
330
+ return [ ISOLATED , script , ...testArgs ] ;
329
331
}
330
332
331
333
//============================
@@ -334,7 +336,7 @@ export namespace scripts {
334
336
export function visualstudio_py_testlauncher ( testArgs : string [ ] ) : string [ ] {
335
337
const script = path . join ( SCRIPTS_DIR , 'visualstudio_py_testlauncher.py' ) ;
336
338
// There is no output to parse, so we do not return a function.
337
- return [ script , ...testArgs ] ;
339
+ return [ ISOLATED , script , ...testArgs ] ;
338
340
}
339
341
340
342
//============================
@@ -384,6 +386,9 @@ export namespace scripts {
384
386
385
387
export function run_adapter ( adapterArgs : string [ ] ) : [ string [ ] , ( out : string ) => DiscoveredTests [ ] ] {
386
388
const script = path . join ( _SCRIPTS_DIR , 'run_adapter.py' ) ;
389
+ // Note that we for now we do not run this "isolated". The
390
+ // script relies on some magic that conflicts with the
391
+ // isolated script.
387
392
const args = [ script , ...adapterArgs ] ;
388
393
389
394
function parse ( out : string ) : DiscoveredTests [ ] {
@@ -418,7 +423,7 @@ export namespace scripts {
418
423
export function getJupyterVariableDataFrameInfo ( ) : string [ ] {
419
424
const script = path . join ( _SCRIPTS_DIR , 'getJupyterVariableDataFrameInfo.py' ) ;
420
425
// There is no script-specific output to parse, so we do not return a function.
421
- return [ script ] ;
426
+ return [ ISOLATED , script ] ;
422
427
}
423
428
424
429
//============================
@@ -427,15 +432,15 @@ export namespace scripts {
427
432
export function getJupyterVariableDataFrameRows ( ) : string [ ] {
428
433
const script = path . join ( _SCRIPTS_DIR , 'getJupyterVariableDataFrameRows.py' ) ;
429
434
// There is no script-specific output to parse, so we do not return a function.
430
- return [ script ] ;
435
+ return [ ISOLATED , script ] ;
431
436
}
432
437
433
438
//============================
434
439
// getServerInfo.py
435
440
436
441
export function getServerInfo ( ) : [ string [ ] , ( out : string ) => JupyterServerInfo [ ] ] {
437
442
const script = path . join ( _SCRIPTS_DIR , 'getServerInfo.py' ) ;
438
- const args = [ script ] ;
443
+ const args = [ ISOLATED , script ] ;
439
444
440
445
function parse ( out : string ) : JupyterServerInfo [ ] {
441
446
return JSON . parse ( out . trim ( ) ) ;
@@ -450,7 +455,7 @@ export namespace scripts {
450
455
export function getJupyterKernels ( ) : string [ ] {
451
456
const script = path . join ( _SCRIPTS_DIR , 'getJupyterKernels.py' ) ;
452
457
// There is no script-specific output to parse, so we do not return a function.
453
- return [ script ] ;
458
+ return [ ISOLATED , script ] ;
454
459
}
455
460
456
461
//============================
@@ -459,15 +464,15 @@ export namespace scripts {
459
464
export function getJupyterKernelspecVersion ( ) : string [ ] {
460
465
const script = path . join ( _SCRIPTS_DIR , 'getJupyterKernelspecVersion.py' ) ;
461
466
// For now we do not worry about parsing the output here.
462
- return [ script ] ;
467
+ return [ ISOLATED , script ] ;
463
468
}
464
469
465
470
//============================
466
471
// jupyter_nbInstalled.py
467
472
468
473
export function jupyter_nbInstalled ( ) : [ string [ ] , ( out : string ) => boolean ] {
469
474
const script = path . join ( _SCRIPTS_DIR , 'jupyter_nbInstalled.py' ) ;
470
- const args = [ script ] ;
475
+ const args = [ ISOLATED , script ] ;
471
476
472
477
function parse ( out : string ) : boolean {
473
478
return out . toLowerCase ( ) . includes ( 'available' ) ;
0 commit comments