Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: install pipx using apt without a prefix on Linux #230

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading