@@ -8,6 +8,8 @@ import { PythonVersionInfo } from '../../types';
88// It is simpler to hard-code it instead of using vscode.ExtensionContext.extensionPath.
99export const _SCRIPTS_DIR = path . join ( EXTENSION_ROOT_DIR , 'pythonFiles' ) ;
1010const SCRIPTS_DIR = _SCRIPTS_DIR ;
11+ export const _ISOLATED = path . join ( _SCRIPTS_DIR , 'pyvsc-run-isolated.py' ) ;
12+ const ISOLATED = _ISOLATED ;
1113
1214// "scripts" contains everything relevant to the scripts found under
1315// the top-level "pythonFiles" directory. Each of those scripts has
@@ -48,7 +50,7 @@ type PythonEnvInfo = {
4850
4951export function interpreterInfo ( ) : [ string [ ] , ( out : string ) => PythonEnvInfo ] {
5052 const script = path . join ( SCRIPTS_DIR , 'interpreterInfo.py' ) ;
51- const args = [ script ] ;
53+ const args = [ ISOLATED , script ] ;
5254
5355 function parse ( out : string ) : PythonEnvInfo {
5456 let json : PythonEnvInfo ;
@@ -158,7 +160,7 @@ namespace _completion {
158160
159161export function completion ( jediPath ?: string ) : [ string [ ] , ( out : string ) => _completion . Response [ ] ] {
160162 const script = path . join ( SCRIPTS_DIR , 'completion.py' ) ;
161- const args = [ script ] ;
163+ const args = [ ISOLATED , script ] ;
162164 if ( jediPath ) {
163165 args . push ( 'custom' ) ;
164166 args . push ( jediPath ) ;
@@ -176,7 +178,7 @@ export function completion(jediPath?: string): [string[], (out: string) => _comp
176178
177179export function sortImports ( filename : string , sortArgs ?: string [ ] ) : [ string [ ] , ( out : string ) => string ] {
178180 const script = path . join ( SCRIPTS_DIR , 'sortImports.py' ) ;
179- const args = [ script , filename , '--diff' ] ;
181+ const args = [ ISOLATED , script , filename , '--diff' ] ;
180182 if ( sortArgs ) {
181183 args . push ( ...sortArgs ) ;
182184 }
@@ -194,7 +196,7 @@ export function sortImports(filename: string, sortArgs?: string[]): [string[], (
194196
195197export function refactor ( root : string ) : [ string [ ] , ( out : string ) => object [ ] ] {
196198 const script = path . join ( SCRIPTS_DIR , 'refactor.py' ) ;
197- const args = [ script , root ] ;
199+ const args = [ ISOLATED , script , root ] ;
198200
199201 // tslint:disable-next-line:no-suspicious-comment
200202 // TODO: Make the return type more specific, like we did
@@ -216,7 +218,7 @@ export function refactor(root: string): [string[], (out: string) => object[]] {
216218
217219export function normalizeForInterpreter ( code : string ) : [ string [ ] , ( out : string ) => string ] {
218220 const script = path . join ( SCRIPTS_DIR , 'normalizeForInterpreter.py' ) ;
219- const args = [ script , code ] ;
221+ const args = [ ISOLATED , script , code ] ;
220222
221223 function parse ( out : string ) {
222224 // The text will be used as-is.
@@ -256,7 +258,7 @@ export function symbolProvider(
256258 text ?: string
257259) : [ string [ ] , ( out : string ) => _symbolProvider . Symbols ] {
258260 const script = path . join ( SCRIPTS_DIR , 'symbolProvider.py' ) ;
259- const args = [ script , filename ] ;
261+ const args = [ ISOLATED , script , filename ] ;
260262 if ( text ) {
261263 args . push ( text ) ;
262264 }
@@ -273,7 +275,7 @@ export function symbolProvider(
273275
274276export function printEnvVariables ( ) : [ string [ ] , ( out : string ) => NodeJS . ProcessEnv ] {
275277 const script = path . join ( SCRIPTS_DIR , 'printEnvVariables.py' ) . fileToCommandArgument ( ) ;
276- const args = [ script ] ;
278+ const args = [ ISOLATED , script ] ;
277279
278280 function parse ( out : string ) : NodeJS . ProcessEnv {
279281 return JSON . parse ( out ) ;
@@ -287,7 +289,7 @@ export function printEnvVariables(): [string[], (out: string) => NodeJS.ProcessE
287289
288290export function printEnvVariablesToFile ( filename : string ) : [ string [ ] , ( out : string ) => NodeJS . ProcessEnv ] {
289291 const script = path . join ( SCRIPTS_DIR , 'printEnvVariablesToFile.py' ) ;
290- const args = [ script , filename . fileToCommandArgument ( ) ] ;
292+ const args = [ ISOLATED , script , filename . fileToCommandArgument ( ) ] ;
291293
292294 function parse ( out : string ) : NodeJS . ProcessEnv {
293295 return JSON . parse ( out ) ;
@@ -304,6 +306,7 @@ export function shell_exec(command: string, lockfile: string, shellArgs: string[
304306 // We don't bother with a "parse" function since the output
305307 // could be anything.
306308 return [
309+ ISOLATED ,
307310 script ,
308311 command . fileToCommandArgument ( ) ,
309312 // The shell args must come after the command
@@ -319,7 +322,7 @@ export function shell_exec(command: string, lockfile: string, shellArgs: string[
319322export function testlauncher ( testArgs : string [ ] ) : string [ ] {
320323 const script = path . join ( SCRIPTS_DIR , 'testlauncher.py' ) ;
321324 // There is no output to parse, so we do not return a function.
322- return [ script , ...testArgs ] ;
325+ return [ ISOLATED , script , ...testArgs ] ;
323326}
324327
325328//============================
@@ -328,5 +331,5 @@ export function testlauncher(testArgs: string[]): string[] {
328331export function visualstudio_py_testlauncher ( testArgs : string [ ] ) : string [ ] {
329332 const script = path . join ( SCRIPTS_DIR , 'visualstudio_py_testlauncher.py' ) ;
330333 // There is no output to parse, so we do not return a function.
331- return [ script , ...testArgs ] ;
334+ return [ ISOLATED , script , ...testArgs ] ;
332335}
0 commit comments