fix: add the python base_exec_prefix path for all OS

This commit is contained in:
Amin Yahyaabadi 2022-11-04 13:57:52 -07:00
parent d2f3163daf
commit 2dde08dd51
6 changed files with 15 additions and 30 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -48,7 +48,7 @@ export async function setupPythonViaSystem(
join(setupDir, "python.exe")
const pythonSetupDir = dirname(pythonBinPath)
/** The directory which the tool is installed to */
await activateWinPython(pythonSetupDir)
await addPath(pythonSetupDir)
return { installDir: pythonSetupDir, binDir: pythonSetupDir }
}
case "darwin": {
@ -75,8 +75,3 @@ export async function setupPythonViaSystem(
}
}
}
async function activateWinPython(binDir: string) {
info(`Add ${binDir} to PATH`)
await addPath(binDir)
}

View File

@ -65,27 +65,17 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
})
if (binDir === undefined) {
if (process.platform === "linux") {
binDir = "/home/runner/.local/bin/"
} else if (process.platform === "darwin") {
binDir = "/usr/local/bin/"
} else {
// windows or others
try {
binDir = join(
(await getExecOutput(`${python} -c "import sys;print(sys.base_exec_prefix);"`)).stdout.trim(),
"Scripts"
)
} catch {
binDir = join(
(await getExecOutput(`${python} -c "import sys;print(sys.base_exec_prefix);"`)).stdout.trim(),
"Scripts"
)
}
}
info(`${binDir} to PATH`)
await addPath(binDir)
binDir = await addPythonBaseExecPrefix()
}
return { binDir }
}
async function addPythonBaseExecPrefix() {
const base_exec_prefix = join(
(await getExecOutput(`${python} -c "import sys;print(sys.base_exec_prefix);"`)).stdout.trim(),
"Scripts"
)
await addPath(base_exec_prefix)
return base_exec_prefix
}