Skip to content

Commit 7523d16

Browse files
committed
fix: check if the pip executable is working on windows
1 parent 9a6f974 commit 7523d16

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

dist/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/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.

src/python/python.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function setupPython(version: string, setupDir: string, arch: string) {
2323
export async function setupPythonViaSystem(version: string, setupDir: string, _arch: string) {
2424
switch (process.platform) {
2525
case "win32": {
26-
await setupChocoPack("python3", version, [`/InstallDir:${setupDir}`])
26+
setupChocoPack("python3", version, setupDir ? [`/InstallDir:${setupDir}`] : [])
2727
// Adding the bin dir to the path
2828
/** The directory which the tool is installed to */
2929
activateWinPython(setupDir)

src/utils/setup/setupPipPack.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { addPath } from "../path/addPath"
77
import { setupPython } from "../../python/python"
88
import { isBinUptoDate } from "./version"
99
import { join } from "path"
10+
import { getVersion } from "../../default_versions"
1011

1112
let pip: string | undefined
1213

@@ -25,6 +26,15 @@ export async function setupPipPack(name: string, version?: string) {
2526
pip = "pip3"
2627
}
2728
}
29+
if (process.platform === "win32") {
30+
try {
31+
// test if pip executable is working
32+
await execa(pip, ["--version"], { stdio: "inherit" })
33+
} catch (err) {
34+
await setupPython(getVersion("python", undefined), "", process.arch)
35+
pip = "pip3"
36+
}
37+
}
2838

2939
execa.sync(pip, ["install", version !== undefined && version !== "" ? `${name}==${version}` : name], {
3040
stdio: "inherit",

0 commit comments

Comments
 (0)