Skip to content

Commit c37190b

Browse files
authored
Merge pull request #5348 from cloudflare/dominik/normalise-dynlib-path
Normalise path before passing to loadDynlib in Python Workers.
2 parents 5708471 + ae34536 commit c37190b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/pyodide/internal/snapshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ function preloadDynamicLibsMain(Module: Module, loadOrder: string[]): void {
348348
base = dynlibPath;
349349
}
350350

351-
const pathSplit = path.split('/');
351+
const pathSplit = Module.PATH.normalizeArray(path.split('/'), true);
352352
if (pathSplit[0] == '') {
353353
// This is a file path beginning with `/`, like /session/metadata/vendor/pkg/lib.so. So we
354354
// are loading the vendored package's dynlibs here.

src/pyodide/types/emscripten.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ interface DSO {
5656
exports: WebAssembly.Exports;
5757
}
5858

59+
// https://github.com/emscripten-core/emscripten/blob/main/src/lib/libpath.js
60+
interface PATH {
61+
normalizeArray: (parts: string[], allowAboveRoot: boolean) => string[];
62+
}
63+
5964
type PreRunHook = (mod: Module) => void;
6065

6166
interface EmscriptenSettings {
@@ -84,6 +89,7 @@ interface Module {
8489
API: API;
8590
ENV: ENV;
8691
LDSO: LDSO;
92+
PATH: PATH;
8793
newDSO: (path: string, opt: object | undefined, handle: string) => DSO;
8894
_Py_Version: number;
8995
_py_version_major?: () => number;

0 commit comments

Comments
 (0)