mirror of https://github.com/aminya/setup-cpp
fix: use an absolute path to pip3 and python on windows
This commit is contained in:
parent
8daf6389ac
commit
488c981727
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -19,7 +19,6 @@ specifiers:
|
||||||
cross-spawn: ^7.0.3
|
cross-spawn: ^7.0.3
|
||||||
eslint-config-atomic: ^1.16.6
|
eslint-config-atomic: ^1.16.6
|
||||||
execa: ^5.1.1
|
execa: ^5.1.1
|
||||||
hasha: ^5.2.2
|
|
||||||
jest: ^27.4.7
|
jest: ^27.4.7
|
||||||
mri: ^1.2.0
|
mri: ^1.2.0
|
||||||
msvc-dev-cmd: git://github.com/aminya/msvc-dev-cmd#9f672c1
|
msvc-dev-cmd: git://github.com/aminya/msvc-dev-cmd#9f672c1
|
||||||
|
@ -41,7 +40,6 @@ dependencies:
|
||||||
'@actions/io': 1.1.1
|
'@actions/io': 1.1.1
|
||||||
'@actions/tool-cache': 1.7.1
|
'@actions/tool-cache': 1.7.1
|
||||||
execa: 5.1.1
|
execa: 5.1.1
|
||||||
hasha: 5.2.2
|
|
||||||
mri: 1.2.0
|
mri: 1.2.0
|
||||||
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
|
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
|
||||||
semver: 7.3.5
|
semver: 7.3.5
|
||||||
|
@ -4378,14 +4376,6 @@ packages:
|
||||||
minimalistic-assert: 1.0.1
|
minimalistic-assert: 1.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/hasha/5.2.2:
|
|
||||||
resolution: {integrity: sha512-Hrp5vIK/xr5SkeN2onO32H0MgNZ0f17HRNH39WfL0SYUNOTZ5Lz1TJ8Pajo/87dYGEFlLMm7mIc/k/s6Bvz9HQ==}
|
|
||||||
engines: {node: '>=8'}
|
|
||||||
dependencies:
|
|
||||||
is-stream: 2.0.1
|
|
||||||
type-fest: 0.8.1
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/highlight.js/10.4.1:
|
/highlight.js/10.4.1:
|
||||||
resolution: {integrity: sha512-yR5lWvNz7c85OhVAEAeFhVCc/GV4C30Fjzc/rCP0aCWzc1UUOPUk55dK/qdwTZHBvMZo+eZ2jpk62ndX/xMFlg==}
|
resolution: {integrity: sha512-yR5lWvNz7c85OhVAEAeFhVCc/GV4C30Fjzc/rCP0aCWzc1UUOPUk55dK/qdwTZHBvMZo+eZ2jpk62ndX/xMFlg==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -7771,6 +7761,7 @@ packages:
|
||||||
/type-fest/0.8.1:
|
/type-fest/0.8.1:
|
||||||
resolution: {integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==}
|
resolution: {integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/typedarray-to-buffer/3.1.5:
|
/typedarray-to-buffer/3.1.5:
|
||||||
resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==}
|
resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { getVersion } from "../../default_versions"
|
||||||
import { untildify_user as untildify } from "../path/untildify"
|
import { untildify_user as untildify } from "../path/untildify"
|
||||||
|
|
||||||
let pip: string | undefined
|
let pip: string | undefined
|
||||||
|
let python: string = "python3"
|
||||||
|
|
||||||
let binDir: string | undefined
|
let binDir: string | undefined
|
||||||
|
|
||||||
|
@ -18,6 +19,15 @@ let binDir: string | undefined
|
||||||
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
|
||||||
if (pip === undefined) {
|
if (pip === undefined) {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
const installationInfo = await setupPython(getVersion("python", undefined), untildify("python"), process.arch)
|
||||||
|
if (installationInfo?.installDir !== undefined) {
|
||||||
|
pip = join(installationInfo.installDir, "Scripts", "pip3.exe")
|
||||||
|
python = join(installationInfo.installDir, "python.exe")
|
||||||
|
} else {
|
||||||
|
pip = "pip3"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (which.sync("pip3", { nothrow: true }) !== null) {
|
if (which.sync("pip3", { nothrow: true }) !== null) {
|
||||||
pip = "pip3"
|
pip = "pip3"
|
||||||
} else if (which.sync("pip", { nothrow: true }) !== null && (await isBinUptoDate("python", "3.0.0"))) {
|
} else if (which.sync("pip", { nothrow: true }) !== null && (await isBinUptoDate("python", "3.0.0"))) {
|
||||||
|
@ -27,14 +37,6 @@ export async function setupPipPack(name: string, version?: string) {
|
||||||
pip = "pip3"
|
pip = "pip3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (process.platform === "win32") {
|
|
||||||
try {
|
|
||||||
// test if pip executable is working
|
|
||||||
await execa(pip, ["--version"], { stdio: "inherit" })
|
|
||||||
} catch (err) {
|
|
||||||
await setupPython(getVersion("python", undefined), untildify("python"), process.arch)
|
|
||||||
pip = "pip3"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
execa.sync(pip, ["install", version !== undefined && version !== "" ? `${name}==${version}` : name], {
|
execa.sync(pip, ["install", version !== undefined && version !== "" ? `${name}==${version}` : name], {
|
||||||
|
@ -47,9 +49,10 @@ export async function setupPipPack(name: string, version?: string) {
|
||||||
} else if (process.platform === "darwin") {
|
} else if (process.platform === "darwin") {
|
||||||
binDir = "/usr/local/bin/"
|
binDir = "/usr/local/bin/"
|
||||||
} else {
|
} else {
|
||||||
|
// windows or others
|
||||||
try {
|
try {
|
||||||
binDir = join(
|
binDir = join(
|
||||||
(await getExecOutput('python3 -c "import sys;print(sys.base_exec_prefix);"')).stdout.trim(),
|
(await getExecOutput(`${python} -c "import sys;print(sys.base_exec_prefix);"`)).stdout.trim(),
|
||||||
"Scripts"
|
"Scripts"
|
||||||
)
|
)
|
||||||
} catch {
|
} catch {
|
||||||
|
|
Loading…
Reference in New Issue