Skip to content

Commit 8b1e805

Browse files
committed
fix: skip double pipx installation if not needed
1 parent af1b02b commit 8b1e805

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ jobs:
228228
node ./dist/legacy/setup-cpp.js --gcc true --cmake true
229229
230230
Docker:
231-
name: Docker-${{ matrix.container.image }}-${{ matrix.platform }}
231+
name: Docker-${{ matrix.container.image }}-${{ matrix.platform }}-${{ matrix.container.tag }}
232232
needs: [Build]
233233
runs-on: ${{ matrix.os }}
234234
strategy:

dist/legacy/setup-cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/python/python.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,35 @@ export async function setupPython(
5959
async function setupPipx(foundPython: string) {
6060
try {
6161
if (!(await hasPipxModule(foundPython))) {
62+
// install pipx for the system-wide python
6263
try {
63-
// first try with the system-wide pipx
6464
await setupPipPackSystem("pipx", isArch())
65-
// then install with the system-wide pipx
66-
await setupPipPackWithPython(foundPython, "pipx", undefined, { upgrade: true, usePipx: false })
6765
} catch (err) {
68-
throw new Error(`pipx was not installed completely: ${err}`)
66+
notice(`pipx was not installed completely for the system-wide python: ${err}`)
67+
}
68+
69+
// install pipx for the given python if the system-wide pipx is different for the given python
70+
try {
71+
if (!(await hasPipxModule(foundPython))) {
72+
await setupPipPackWithPython(foundPython, "pipx", undefined, { upgrade: true, usePipx: false })
73+
}
74+
} catch (err) {
75+
notice(`pipx was not installed completely for ${foundPython}: ${err}`)
6976
}
7077
}
78+
79+
// install ensurepath for the given python
7180
if (await hasPipxModule(foundPython)) {
7281
await execa(foundPython, ["-m", "pipx", "ensurepath"], { stdio: "inherit" })
73-
return
7482
} else if (await hasPipxBinary()) {
75-
notice("pipx module not found. Trying to install with pipx binary...")
83+
// install ensurepath with the pipx binary
84+
notice(`pipx module not found for ${foundPython}. Trying to install with pipx binary...`)
7685
await execa("pipx", ["ensurepath"], { stdio: "inherit" })
77-
return
7886
} else {
7987
throw new Error("pipx module or pipx binary not found. Corrput pipx installation.")
8088
}
8189
} catch (err) {
82-
notice(`Failed to install pipx: ${(err as Error).toString()}. Ignoring...`)
90+
notice(`Failed to install pipx completely for ${foundPython}: ${(err as Error).toString()}. Ignoring...`)
8391
}
8492
}
8593

0 commit comments

Comments
 (0)