8000 fix: macos lib finder maybe hopefully · tjosepo/deno_python@81258dd · GitHub
[go: up one dir, main page]

Skip to content

Commit 81258dd

Browse files
committed
fix: macos lib finder maybe hopefully
1 parent 5581c03 commit 81258dd

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/util.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,24 @@ async function findlibs(): Promise<string[]> {
7979
libs.concat(await search(location));
8080
}
8181
} else {
82-
for (const path of ["/usr/lib", "/lib"]) {
82+
const paths = ["/usr/lib", "/lib"];
83+
84+
if (Deno.build.os === "darwin") {
85+
paths.push(
86+
"/System/Library",
87+
"/opt/homebrew/Frameworks",
88+
"/usr/local/Frameworks",
89+
);
90+
91+
for (const [major, minor] of versions) {
92+
const path = `Python.framework/Versions/${major}.${minor}/Python`;
93+
if (await exists(path)) {
94+
paths.push(path);
95+
}
96+
}
97+
}
98+
99+
for (const path of paths) {
83100
for (
84101
const location of await find(path, `libpython*.${extension}`)
85102
) {
@@ -89,15 +106,15 @@ async function findlibs(): Promise<string[]> {
89106
}
90107

91108
for (
92-
const path of Deno.env.get(
109+
const location of Deno.env.get(
93110
Deno.build.os === "windows"
94111
? "PATH"
95112
: Deno.build.os === "darwin"
96113
? "DYLD_LIBRARY_PATH"
97114
: "LD_LIBRARY_PATH",
98115
)?.split(Deno.build.os === "windows" ? ";" : ":") ?? []
99116
) {
100-
libs.concat(await search(path));
117+
libs.concat(await search(location));
101118
}
102119

103120
return [...new Set(libs)];
@@ -113,7 +130,11 @@ export async function findlib(): Promise<string> {
113130
const filename = `${prefix}python${version}.${extension}`;
114131

115132
for (const candidate of candidates) {
116-
if (candidate.endsWith(filename)) {
133+
if (
134+
candidate.endsWith(filename) ||
135+
(Deno.build.os === "darwin" &&
136+
candidate === `Python.framework/Versions/${major}.${minor}/Python`)
137+
) {
117138
return candidate;
118139
}
119140
}

0 commit comments

Comments
 (0)
0