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) { async function setupPipx(foundPython: string) {
try { try {
if (!(await hasPipx())) { if (!(await hasPipx(foundPython))) {
try { try {
await setupPipPackWithPython(foundPython, "pipx", undefined, true) await setupPipPackWithPython(foundPython, "pipx", undefined, true)
} catch (err) { } catch (err) {

View File

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