fix: install pipx using apt without a prefix on Linux

This commit is contained in:
Amin Yahyaabadi 2024-02-14 04:16:39 -08:00
parent 4e8c2f8bfb
commit 5eefa3d4ef
8 changed files with 17 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

@ -44,7 +44,13 @@ 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(foundPython))) { if (!(await hasPipx(foundPython))) {
await setupPipPackWithPython(foundPython, "pipx", undefined, { upgrade: true, usePipx: false }) try {
await setupPipPackWithPython(foundPython, "pipx", undefined, { upgrade: true, usePipx: false })
} catch (err) {
if (setupPipPackSystem("pipx", false) === null) {
throw new Error(`pipx was not installed correctly ${err}`)
}
}
} }
await execa(foundPython, ["-m", "pipx", "ensurepath"], { stdio: "inherit" }) await execa(foundPython, ["-m", "pipx", "ensurepath"], { stdio: "inherit" })
await setupPipPackWithPython(foundPython, "venv", undefined, { upgrade: false, usePipx: false }) await setupPipPackWithPython(foundPython, "venv", undefined, { upgrade: false, usePipx: false })

View File

@ -174,15 +174,15 @@ async function findBinDir(dirs: string[], name: string) {
return dirs[dirs.length - 1] return dirs[dirs.length - 1]
} }
export function setupPipPackSystem(name: string) { export function setupPipPackSystem(name: string, addPythonPrefix = true) {
if (process.platform === "linux") { if (process.platform === "linux") {
info(`Installing ${name} via the system package manager`) info(`Installing ${name} via the system package manager`)
if (isArch()) { if (isArch()) {
return setupPacmanPack(`python-${name}`) return setupPacmanPack(addPythonPrefix ? `python-${name}` : name)
} else if (hasDnf()) { } else if (hasDnf()) {
return setupDnfPack([{ name: `python3-${name}` }]) return setupDnfPack([{ name: addPythonPrefix ? `python3-${name}` : name }])
} else if (isUbuntu()) { } else if (isUbuntu()) {
return setupAptPack([{ name: `python3-${name}` }]) return setupAptPack([{ name: addPythonPrefix ? `python3-${name}` : name }])
} }
} }
return null return null