Fix Windows Python spawning

This commit is contained in:
2026-04-30 03:43:17 +09:00
parent bb965c061e
commit 178283be61
5 changed files with 11 additions and 5 deletions

View File

@@ -17,6 +17,7 @@ function splitCommandSpec(spec: string): string[] {
function canRun(command: string, args: string[]): boolean {
const result = spawnSync(command, [...args, "--version"], {
encoding: "utf8",
shell: process.platform === "win32",
});
return result.error == null && result.status === 0;
}

View File

@@ -111,6 +111,7 @@ export class PythonJsonWorker {
const child = spawn(launch.command, [...launch.args, scriptPath], {
stdio: ["pipe", "pipe", "pipe"],
shell: process.platform === "win32",
env: {
...process.env,
HF_HOME: cachePath,

View File

@@ -10,6 +10,7 @@ async function run(command: string, args: string[], extraEnv?: NodeJS.ProcessEnv
await new Promise<void>((resolve, reject) => {
const child = spawn(command, args, {
stdio: "inherit",
shell: process.platform === "win32",
env: {
...process.env,
...extraEnv,
@@ -31,6 +32,7 @@ async function ensurePip(pythonBin: string, env: NodeJS.ProcessEnv): Promise<voi
await new Promise<void>((resolve, reject) => {
const child = spawn(pythonBin, ["-m", "pip", "--version"], {
stdio: "ignore",
shell: process.platform === "win32",
env,
});
child.on("exit", (code) => {