Skip to content

Commit 34ce598

Browse files
committed
fix: use explicit pyodide.loadPackage() instead of packages parameter
The packages parameter in loadPyodide() appears unreliable in CI environments. Instead, load Pyodide first, then explicitly load packages using pyodide.loadPackage() to ensure they're actually available.
1 parent 2ae84fe commit 34ce598

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

packages/pyodide-runtime-agent/src/pyodide-worker.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,9 @@ async function initializePyodide(
8181
data: `Using cache directory: ${packageCacheDir}`,
8282
});
8383

84-
// Load Pyodide with packages in parallel for faster initialization
84+
// Load Pyodide first without packages (more reliable in CI)
8585
pyodide = await loadPyodide({
8686
packageCacheDir,
87-
packages: packagesForInit, // Load packages in parallel with Pyodide initialization
8887
stdout: (text: string) => {
8988
self.postMessage({
9089
type: "stream_output",
@@ -99,17 +98,25 @@ async function initializePyodide(
9998
},
10099
});
101100

101+
// Explicitly load packages after Pyodide is initialized
102+
self.postMessage({
103+
type: "log",
104+
data: `Explicitly loading packages: ${packagesForInit.join(", ")}`,
105+
});
106+
107+
await pyodide.loadPackage(packagesForInit);
108+
102109
// Set up interrupt buffer
103110
if (interruptBuffer) {
104111
const interruptView = new Int32Array(interruptBuffer);
105112
pyodide.setInterruptBuffer(interruptView);
106113
self.postMessage({ type: "log", data: "Interrupt buffer configured" });
107114
}
108115

109-
// Packages are already loaded in parallel during Pyodide initialization
116+
// Packages have been explicitly loaded after Pyodide initialization
110117
self.postMessage({
111118
type: "log",
112-
data: `Packages loaded in parallel: ${packagesForInit.join(", ")}`,
119+
data: `Packages loaded successfully: ${packagesForInit.join(", ")}`,
113120
});
114121

115122
// Load our Python bootstrap file

0 commit comments

Comments
 (0)