diff --git a/src/workerd/api/BUILD.bazel b/src/workerd/api/BUILD.bazel index 771df5cd803..61625d9121a 100644 --- a/src/workerd/api/BUILD.bazel +++ b/src/workerd/api/BUILD.bazel @@ -136,7 +136,6 @@ wd_cc_library( hdrs = [ "pyodide/pyodide.h", "pyodide/setup-emscripten.h", - "//src/pyodide:generated/pyodide_extra.capnp.h", ], implementation_deps = ["//src/workerd/util:string-buffer"], visibility = ["//visibility:public"], diff --git a/src/workerd/api/pyodide/pyodide.h b/src/workerd/api/pyodide/pyodide.h index f403ef7b684..3f932809e62 100644 --- a/src/workerd/api/pyodide/pyodide.h +++ b/src/workerd/api/pyodide/pyodide.h @@ -13,8 +13,6 @@ #include #include -#include - #include #include #include diff --git a/src/workerd/server/tests/python/BUILD.bazel b/src/workerd/server/tests/python/BUILD.bazel index 79b91e6956c..450650b77f7 100644 --- a/src/workerd/server/tests/python/BUILD.bazel +++ b/src/workerd/server/tests/python/BUILD.bazel @@ -30,6 +30,7 @@ py_wd_test("subdirectory") py_wd_test( "sdk", + # TODO(EW-8976): Disabled in dev due to test getting stuck python_flags = ["0.26.0a2"], tags = [ # TODO(someday): Fix asan failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318 diff --git a/src/workerd/server/workerd-api.c++ b/src/workerd/server/workerd-api.c++ index fa9892f508b..b574b84ecb5 100644 --- a/src/workerd/server/workerd-api.c++ +++ b/src/workerd/server/workerd-api.c++ @@ -46,6 +46,8 @@ #include #include +#include + #include #include #include @@ -157,6 +159,7 @@ void writePyodideBundleFileToDisk(const kj::Maybe>& replacer->commit(); } } +} // namespace kj::Maybe fetchPyodideBundle( const api::pyodide::PythonConfig& pyConfig, kj::StringPtr version) { @@ -213,7 +216,6 @@ kj::Maybe fetchPyodideBundle( KJ_LOG(INFO, "Loaded Pyodide package from internet"); return pyConfig.pyodideBundleManager.getPyodideBundle(version); } -} // namespace struct WorkerdApi::Impl final { kj::Own features; diff --git a/src/workerd/server/workerd-api.h b/src/workerd/server/workerd-api.h index 8fedc9ccbee..a453200562f 100644 --- a/src/workerd/server/workerd-api.h +++ b/src/workerd/server/workerd-api.h @@ -265,4 +265,7 @@ class WorkerdApi final: public Worker::Api { capnp::List::Reader extensions) const; }; +kj::Maybe fetchPyodideBundle( + const api::pyodide::PythonConfig& pyConfig, kj::StringPtr version); + } // namespace workerd::server diff --git a/src/workerd/server/workerd.c++ b/src/workerd/server/workerd.c++ index d7f1403cc0e..1dbb1aa1476 100644 --- a/src/workerd/server/workerd.c++ +++ b/src/workerd/server/workerd.c++ @@ -3,8 +3,10 @@ // https://opensource.org/licenses/Apache-2.0 #include "server.h" +#include "workerd-api.h" #include +#include #include #include #include @@ -15,7 +17,6 @@ #include #include -#include #include #include @@ -807,7 +808,24 @@ class CliMain final: public SchemaFileImpl::ErrorReporter { context, getVersionString(), "Outputs the package lock file used by Pyodide."); return builder .callAfterParsing([]() -> kj::MainBuilder::Validity { - printf("%s\n", PYODIDE_LOCK->cStr()); + static const PythonConfig config{ + .packageDiskCacheRoot = kj::none, + .pyodideDiskCacheRoot = kj::none, + .createSnapshot = false, + .createBaselineSnapshot = false, + }; + + capnp::MallocMessageBuilder message; + // TODO(EW-8977): Implement option to specify python worker flags. + auto features = message.getRoot(); + features.setPythonWorkers(true); + auto pythonRelease = KJ_ASSERT_NONNULL(getPythonSnapshotRelease(features)); + auto version = getPythonBundleName(pythonRelease); + KJ_ASSERT_NONNULL(fetchPyodideBundle(config, version), "Failed to get Pyodide bundle"); + + auto lock = KJ_ASSERT_NONNULL(config.pyodideBundleManager.getPyodideLock(pythonRelease)); + + printf("%s\n", lock.cStr()); fflush(stdout); return true; }).build();