Skip to content

Commit

Permalink
fix: install pipx using apt without a prefix on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Feb 14, 2024
1 parent 4e8c2f8 commit 5eefa3d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dist/actions/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/actions/setup-cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/python/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
8 changes: 4 additions & 4 deletions src/utils/setup/setupPipPack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5eefa3d

Please sign in to comment.