fix: fix checking for pipx existence

This commit is contained in:
Amin Yahyaabadi 2023-09-01 03:10:24 -07:00
parent 512202e7f4
commit 65c4b0f5dc
8 changed files with 11 additions and 11 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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -43,7 +43,7 @@ export async function setupPython(version: string, setupDir: string, arch: strin
async function setupPipx(foundPython: string) {
try {
if (!(await hasPipx())) {
if (!(await hasPipx(foundPython))) {
try {
await setupPipPackWithPython(foundPython, "pipx", undefined, true)
} catch (err) {

View File

@ -1,5 +1,5 @@
import { info } from "@actions/core"
import { execaSync } from "execa"
import { execa, execaSync } from "execa"
import { pathExists } from "path-exists"
import { addExeExt, dirname, join } from "patha"
import which from "which"
@ -22,7 +22,7 @@ export async function setupPipPackWithPython(
upgrade = false,
user = true,
): Promise<InstallationInfo> {
const isPipx = await hasPipx()
const isPipx = await hasPipx(givenPython)
const pip = isPipx ? "pipx" : "pip"
info(`Installing ${name} ${version ?? ""} via ${pip}`)
@ -43,8 +43,8 @@ export async function setupPipPackWithPython(
return { binDir }
}
export async function hasPipx() {
return (await which("pipx", { nothrow: true })) !== null
export async function hasPipx(givenPython: string) {
return (await execa(givenPython, ["-m", "pipx", "--help"], { stdio: "ignore", reject: false })).exitCode === 0
}
async function getPython_raw(): Promise<string> {