mirror of https://github.com/aminya/setup-cpp
fix: fix pip installation path for macos and windows
This commit is contained in:
parent
bf63dd58d3
commit
ecb7cdd120
|
@ -1,5 +1,5 @@
|
||||||
/* eslint-disable require-atomic-updates */
|
/* eslint-disable require-atomic-updates */
|
||||||
import { exec } from "@actions/exec"
|
import { exec, getExecOutput } from "@actions/exec"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
import { addPath, startGroup, endGroup } from "@actions/core"
|
import { addPath, startGroup, endGroup } from "@actions/core"
|
||||||
import { setupPython } from "../../python/python"
|
import { setupPython } from "../../python/python"
|
||||||
|
@ -7,6 +7,8 @@ import { isBinUptoDate } from "./version"
|
||||||
|
|
||||||
let pip: string | undefined
|
let pip: string | undefined
|
||||||
|
|
||||||
|
let binDir: string | undefined
|
||||||
|
|
||||||
/** A function that installs a package using pip */
|
/** A function that installs a package using pip */
|
||||||
export async function setupPipPack(name: string, version?: string) {
|
export async function setupPipPack(name: string, version?: string) {
|
||||||
// setup python and pip if needed
|
// setup python and pip if needed
|
||||||
|
@ -26,17 +28,20 @@ export async function setupPipPack(name: string, version?: string) {
|
||||||
throw new Error(`Failed to install ${name} ${version}`)
|
throw new Error(`Failed to install ${name} ${version}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
let binDir: string | undefined
|
if (binDir === undefined) {
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
try {
|
|
||||||
binDir = "/home/runner/.local/bin/"
|
binDir = "/home/runner/.local/bin/"
|
||||||
|
} else if (process.platform === "darwin") {
|
||||||
|
binDir = "/usr/local/bin/"
|
||||||
|
} else {
|
||||||
|
binDir = (await getExecOutput("python -c 'import sys; print(sys.base_exec_prefix)'")).stdout
|
||||||
|
}
|
||||||
|
try {
|
||||||
startGroup(`${binDir} to PATH`)
|
startGroup(`${binDir} to PATH`)
|
||||||
addPath(binDir)
|
addPath(binDir)
|
||||||
} finally {
|
} finally {
|
||||||
endGroup()
|
endGroup()
|
||||||
}
|
}
|
||||||
} else if (process.platform === "darwin") {
|
|
||||||
binDir = "/usr/local/bin/"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return binDir
|
return binDir
|
||||||
|
|
Loading…
Reference in New Issue