mirror of https://github.com/aminya/setup-cpp
fix: ensure running setup-python in github actions
This commit is contained in:
parent
488c981727
commit
ff997f2c40
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -6,7 +6,7 @@ import { setupChocoPack } from "../utils/setup/setupChocoPack"
|
||||||
import { isGitHubCI } from "../utils/env/isci"
|
import { isGitHubCI } from "../utils/env/isci"
|
||||||
|
|
||||||
export function setupPython(version: string, setupDir: string, arch: string) {
|
export function setupPython(version: string, setupDir: string, arch: string) {
|
||||||
if (!isGitHubCI() || process.platform === "win32") {
|
if (!isGitHubCI()) {
|
||||||
// TODO parse version
|
// TODO parse version
|
||||||
return setupPythonViaSystem(version, setupDir, arch)
|
return setupPythonViaSystem(version, setupDir, arch)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,12 @@ export function setupPython(version: string, setupDir: string, arch: string) {
|
||||||
export async function setupPythonViaSystem(version: string, setupDir: string, _arch: string) {
|
export async function setupPythonViaSystem(version: string, setupDir: string, _arch: string) {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32": {
|
case "win32": {
|
||||||
setupChocoPack("python3", version, setupDir ? [`--params=/InstallDir:${setupDir}`] : [])
|
if (setupDir) {
|
||||||
|
setupChocoPack("python3", version, [`--params=/InstallDir:${setupDir}`])
|
||||||
|
} else {
|
||||||
|
setupChocoPack("python3", version)
|
||||||
|
}
|
||||||
|
|
||||||
// Adding the bin dir to the path
|
// Adding the bin dir to the path
|
||||||
/** The directory which the tool is installed to */
|
/** The directory which the tool is installed to */
|
||||||
activateWinPython(setupDir)
|
activateWinPython(setupDir)
|
||||||
|
|
|
@ -7,11 +7,10 @@ import { addPath } from "../path/addPath"
|
||||||
import { setupPython } from "../../python/python"
|
import { setupPython } from "../../python/python"
|
||||||
import { isBinUptoDate } from "./version"
|
import { isBinUptoDate } from "./version"
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
|
import { isGitHubCI } from "../env/isci"
|
||||||
import { getVersion } from "../../default_versions"
|
import { getVersion } from "../../default_versions"
|
||||||
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
|
||||||
|
|
||||||
|
@ -19,23 +18,17 @@ 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") {
|
if (isGitHubCI() && process.platform === "win32") {
|
||||||
const installationInfo = await setupPython(getVersion("python", undefined), untildify("python"), process.arch)
|
// run setupPython in actions_python anyways
|
||||||
if (installationInfo?.installDir !== undefined) {
|
await setupPython(getVersion("python", undefined), "", process.arch)
|
||||||
pip = join(installationInfo.installDir, "Scripts", "pip3.exe")
|
}
|
||||||
python = join(installationInfo.installDir, "python.exe")
|
if (which.sync("pip3", { nothrow: true }) !== null) {
|
||||||
} else {
|
pip = "pip3"
|
||||||
pip = "pip3"
|
} else if (which.sync("pip", { nothrow: true }) !== null && (await isBinUptoDate("python", "3.0.0"))) {
|
||||||
}
|
pip = "pip"
|
||||||
} else {
|
} else {
|
||||||
if (which.sync("pip3", { nothrow: true }) !== null) {
|
await setupPython("3.x", "", process.arch)
|
||||||
pip = "pip3"
|
pip = "pip3"
|
||||||
} else if (which.sync("pip", { nothrow: true }) !== null && (await isBinUptoDate("python", "3.0.0"))) {
|
|
||||||
pip = "pip"
|
|
||||||
} else {
|
|
||||||
await setupPython("3.x", "", process.arch)
|
|
||||||
pip = "pip3"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +45,7 @@ export async function setupPipPack(name: string, version?: string) {
|
||||||
// windows or others
|
// windows or others
|
||||||
try {
|
try {
|
||||||
binDir = join(
|
binDir = join(
|
||||||
(await getExecOutput(`${python} -c "import sys;print(sys.base_exec_prefix);"`)).stdout.trim(),
|
(await getExecOutput(`python3 -c "import sys;print(sys.base_exec_prefix);"`)).stdout.trim(),
|
||||||
"Scripts"
|
"Scripts"
|
||||||
)
|
)
|
||||||
} catch {
|
} catch {
|
||||||
|
|
Loading…
Reference in New Issue