33
44import { CondaEnvironmentInfo } from '../../pythonEnvironments/discovery/locators/services/conda' ;
55import { InterpreterInformation } from '../../pythonEnvironments/discovery/types' ;
6+ import { getPythonExecInfo , PythonExecInfo } from '../../pythonEnvironments/exec' ;
7+ import { extractInterpreterInfo } from '../../pythonEnvironments/info' ;
68import { traceError , traceInfo } from '../logger' ;
79import { IFileSystem } from '../platform/types' ;
8- import { Architecture } from '../utils/platform' ;
9- import { parsePythonVersion } from '../utils/version' ;
1010import * as internalPython from './internal/python' ;
1111import * as internalScripts from './internal/scripts' ;
12- import { ExecutionResult , IProcessService , PythonExecutionInfo , ShellOptions , SpawnOptions } from './types' ;
13-
14- function getExecutionInfo ( python : string [ ] , pythonArgs : string [ ] ) : PythonExecutionInfo {
15- const args = python . slice ( 1 ) ;
16- args . push ( ...pythonArgs ) ;
17- return { command : python [ 0 ] , args, python } ;
18- }
12+ import { ExecutionResult , IProcessService , ShellOptions , SpawnOptions } from './types' ;
1913
2014class PythonEnvironment {
2115 private cachedInterpreterInformation : InterpreterInformation | undefined | null = null ;
@@ -33,13 +27,13 @@ class PythonEnvironment {
3327 }
3428 ) { }
3529
36- public getExecutionInfo ( pythonArgs : string [ ] = [ ] ) : PythonExecutionInfo {
30+ public getExecutionInfo ( pythonArgs : string [ ] = [ ] ) : PythonExecInfo {
3731 const python = this . deps . getPythonArgv ( this . pythonPath ) ;
38- return getExecutionInfo ( python , pythonArgs ) ;
32+ return getPythonExecInfo ( python , pythonArgs ) ;
3933 }
40- public getExecutionObservableInfo ( pythonArgs : string [ ] = [ ] ) : PythonExecutionInfo {
34+ public getExecutionObservableInfo ( pythonArgs : string [ ] = [ ] ) : PythonExecInfo {
4135 const python = this . deps . getObservablePythonArgv ( this . pythonPath ) ;
42- return getExecutionInfo ( python , pythonArgs ) ;
36+ return getPythonExecInfo ( python , pythonArgs ) ;
4337 }
4438
4539 public async getInterpreterInformation ( ) : Promise < InterpreterInformation | undefined > {
@@ -96,17 +90,7 @@ class PythonEnvironment {
9690 }
9791 const json = parse ( result . stdout ) ;
9892 traceInfo ( `Found interpreter for ${ argv } ` ) ;
99- const versionValue =
100- json . versionInfo . length === 4
101- ? `${ json . versionInfo . slice ( 0 , 3 ) . join ( '.' ) } -${ json . versionInfo [ 3 ] } `
102- : json . versionInfo . join ( '.' ) ;
103- return {
104- architecture : json . is64Bit ? Architecture . x64 : Architecture . x86 ,
105- path : this . pythonPath ,
106- version : parsePythonVersion ( versionValue ) ,
107- sysVersion : json . sysVersion ,
108- sysPrefix : json . sysPrefix
109- } ;
93+ return extractInterpreterInfo ( this . pythonPath , json ) ;
11094 } catch ( ex ) {
11195 traceError ( `Failed to get interpreter information for '${ this . pythonPath } '` , ex ) ;
11296 }
0 commit comments