Skip to content

Commit b3e64ed

Browse files
authored
Merge pull request #3656 from cloudflare/dominik/fix-asgi
Fixes asgi import at top-level failing.
2 parents 445bb4c + 889ec73 commit b3e64ed

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/pyodide/python-entrypoint-helper.ts

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ async function setupPatches(pyodide: Pyodide): Promise<void> {
8080
pyodide.site_packages = `/lib/python${pymajor}.${pyminor}/site-packages`;
8181

8282
// Inject modules that enable JS features to be used idiomatically from Python.
83+
//
84+
// NOTE: setupPatches is called after memorySnapshotDoImports, so any modules injected here
85+
// shouldn't be part of the snapshot and should filtered out in filterPythonScriptImports.
8386
if (USING_OLDEST_PYODIDE_VERSION) {
8487
// Inject at cloudflare.workers for backwards compatibility
8588
pyodide.FS.mkdir(`${pyodide.site_packages}/cloudflare`);

src/workerd/api/pyodide/pyodide.c++

+4-2
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,10 @@ kj::Array<kj::String> PythonModuleInfo::filterPythonScriptImports(
412412
continue;
413413
}
414414

415-
// don't include js or pyodide.
416-
if (firstComponent == "js"_kj.asArray() || firstComponent == "pyodide"_kj.asArray()) {
415+
// don't include modules that we provide and that are likely to be imported by most
416+
// workers.
417+
if (firstComponent == "js"_kj.asArray() || firstComponent == "pyodide"_kj.asArray() ||
418+
firstComponent == "asgi"_kj.asArray() || firstComponent == "workers"_kj.asArray()) {
417419
continue;
418420
}
419421

0 commit comments

Comments
 (0)