forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutable.ts
More file actions
25 lines (22 loc) · 909 Bytes
/
executable.ts
File metadata and controls
25 lines (22 loc) · 909 Bytes
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { getExecutable as getPythonExecutableCommand } from '../../common/process/internal/python';
import { copyPythonExecInfo, PythonExecInfo } from '../exec';
type ExecResult = {
stdout: string;
};
type ExecFunc = (command: string, args: string[]) => Promise<ExecResult>;
/**
* Find the filename for the corresponding Python executable.
*
* Effectively, we look up `sys.executable`.
*
* @param python - the information to use when running Python
* @param exec - the function to use to run Python
*/
export async function getExecutablePath(python: PythonExecInfo, exec: ExecFunc): Promise<string> {
const [args, parse] = getPythonExecutableCommand();
const info = copyPythonExecInfo(python, args);
const result = await exec(info.command, info.args);
return parse(result.stdout);
}