Merge pull request #230 from aminya/pipx [skip ci]

This commit is contained in:
Amin Yahyaabadi 2024-02-16 14:13:27 -08:00 committed by GitHub
commit 88ef2fc50d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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) {
try {
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 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]
}
export function setupPipPackSystem(name: string) {
export function setupPipPackSystem(name: string, addPythonPrefix = true) {
if (process.platform === "linux") {
info(`Installing ${name} via the system package manager`)
if (isArch()) {
return setupPacmanPack(`python-${name}`)
return setupPacmanPack(addPythonPrefix ? `python-${name}` : name)
} else if (hasDnf()) {
return setupDnfPack([{ name: `python3-${name}` }])
return setupDnfPack([{ name: addPythonPrefix ? `python3-${name}` : name }])
} else if (isUbuntu()) {
return setupAptPack([{ name: `python3-${name}` }])
return setupAptPack([{ name: addPythonPrefix ? `python3-${name}` : name }])
}
}
return null