Skip to content

Commit e376f26

Browse files
committed
fix: choose the python binary directory based on the existence
1 parent 0f4b1a6 commit e376f26

File tree

6 files changed

+12
-15
lines changed

6 files changed

+12
-15
lines changed

dist/node12/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/node12/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/node16/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/node16/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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,5 @@ export async function addPythonBaseExecPrefix(python: string) {
149149
// add the directories to the path
150150
await Promise.all(dirs.map((dir) => addPath(dir)))
151151

152-
// the last directory is the bin directory (not empty)
153-
const foundBinDir = dirs.pop()
154-
155-
if (foundBinDir === undefined) {
156-
warning("The binary directory for pip dependencies could not be found")
157-
}
158-
159-
return foundBinDir!
152+
return dirs
160153
}

src/utils/setup/setupPipPack.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import execa from "execa"
33
import { info } from "@actions/core"
44
import { addPythonBaseExecPrefix, setupPythonAndPip } from "../../python/python"
55
import { InstallationInfo } from "./setupBin"
6+
import { existsSync } from "fs"
7+
import { addExeExt, join } from "patha"
68

79
let python: string | undefined
8-
let binDir: string | undefined
10+
let binDirs: string[] | undefined
911

1012
/** A function that installs a package using pip */
1113
export async function setupPipPack(name: string, version?: string): Promise<InstallationInfo> {
@@ -19,9 +21,11 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
1921
stdio: "inherit",
2022
})
2123

22-
if (binDir === undefined) {
23-
binDir = await addPythonBaseExecPrefix(python)
24+
if (binDirs === undefined) {
25+
binDirs = await addPythonBaseExecPrefix(python)
2426
}
2527

28+
const binDir = binDirs.find((dir) => existsSync(join(dir, addExeExt(name)))) ?? binDirs.pop()!
29+
2630
return { binDir }
2731
}

0 commit comments

Comments
 (0)