Simplify Python runtime probing and tests

This commit is contained in:
William Woodruff
2026-09-03 15:35:14 -04:00
parent 70e5842acc
commit ce013a24a4
3 changed files with 103 additions and 232 deletions
+7 -5
View File
@@ -1,8 +1,11 @@
import { execFile } from "node:child_process";
import { join } from "node:path";
import { promisify } from "node:util";
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import type { SetupInputs } from "./inputs";
const execFileAsync = promisify(execFile);
const PYTHON_RUNTIME_QUERY = `
import json
import platform
@@ -69,11 +72,10 @@ export async function getPythonRuntimeId(inputs: SetupInputs): Promise<string> {
: join(inputs.venvPath, "bin", "python");
try {
// @actions/exec parses the executable as a command line, so quote the path.
const { stdout } = await exec.getExecOutput(
`"${pythonPath.replace(/"/g, '\\"')}"`,
const { stdout } = await execFileAsync(
pythonPath,
["-I", "-c", PYTHON_RUNTIME_QUERY],
{ silent: !core.isDebug() },
{ encoding: "utf8" },
);
return formatRuntimeId(JSON.parse(stdout));
} catch (error) {