mirror of https://github.com/aminya/setup-cpp
fix: handle the MacOS/Linux exec prefix paths
This commit is contained in:
parent
2dde08dd51
commit
623216a193
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
|
@ -12,6 +12,8 @@ import { dirname, join } from "patha"
|
|||
import { hasDnf } from "../utils/env/hasDnf"
|
||||
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||
import { getExecOutput } from "@actions/exec"
|
||||
import { existsSync } from "fs"
|
||||
|
||||
export async function setupPython(version: string, setupDir: string, arch: string) {
|
||||
if (ciDetect() !== "github-actions") {
|
||||
|
@ -75,3 +77,33 @@ export async function setupPythonViaSystem(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function addPythonBaseExecPrefix(python: string) {
|
||||
let dirs: string[] = []
|
||||
|
||||
// detection based on the platform
|
||||
if (process.platform === "linux") {
|
||||
dirs.push("/home/runner/.local/bin/")
|
||||
} else if (process.platform === "darwin") {
|
||||
dirs.push("/usr/local/bin/")
|
||||
}
|
||||
|
||||
// detection using python.sys
|
||||
const base_exec_prefix = (await getExecOutput(`${python} -c "import sys;print(sys.base_exec_prefix);"`)).stdout.trim()
|
||||
dirs.push(join(base_exec_prefix, "Scripts"), join(base_exec_prefix, "Scripts", "bin"))
|
||||
|
||||
// exclude the non existing ones
|
||||
dirs = dirs.filter((dir) => existsSync(dir))
|
||||
|
||||
// add the directories to the path
|
||||
await Promise.all(dirs.map((dir) => addPath(dir)))
|
||||
|
||||
// the last directory is the bin directory (not empty)
|
||||
const foundBinDir = dirs.pop()
|
||||
|
||||
if (foundBinDir === undefined) {
|
||||
warning("The binary directory for pip dependencies could not be found")
|
||||
}
|
||||
|
||||
return foundBinDir!
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
/* eslint-disable require-atomic-updates */
|
||||
import { getExecOutput } from "@actions/exec"
|
||||
import execa from "execa"
|
||||
import which from "which"
|
||||
import { info } from "@actions/core"
|
||||
import { addPath } from "../env/addEnv"
|
||||
import { setupPython } from "../../python/python"
|
||||
import { addPythonBaseExecPrefix, setupPython } from "../../python/python"
|
||||
import { isBinUptoDate } from "./version"
|
||||
import { join } from "patha"
|
||||
import { getVersion } from "../../versions/versions"
|
||||
import { InstallationInfo } from "./setupBin"
|
||||
import { setupAptPack } from "./setupAptPack"
|
||||
|
@ -65,17 +62,8 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
|
|||
})
|
||||
|
||||
if (binDir === undefined) {
|
||||
binDir = await addPythonBaseExecPrefix()
|
||||
binDir = await addPythonBaseExecPrefix(python)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue