Skip to content

Commit 29612f9

Browse files
committed
Removes usage of embedded PYODIDE_LOCK in C++ code.
1 parent 8cb7ffd commit 29612f9

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed

src/workerd/api/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ wd_cc_library(
136136
hdrs = [
137137
"pyodide/pyodide.h",
138138
"pyodide/setup-emscripten.h",
139-
"//src/pyodide:generated/pyodide_extra.capnp.h",
140139
],
141140
implementation_deps = ["//src/workerd/util:string-buffer"],
142141
visibility = ["//visibility:public"],

src/workerd/api/pyodide/pyodide.h

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include <workerd/server/workerd.capnp.h>
1414
#include <workerd/util/autogate.h>
1515

16-
#include <pyodide/generated/pyodide_extra.capnp.h>
17-
1816
#include <capnp/serialize.h>
1917
#include <kj/array.h>
2018
#include <kj/common.h>

src/workerd/server/tests/python/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ py_wd_test("subdirectory")
3030

3131
py_wd_test(
3232
"sdk",
33+
# TODO(EW-8976): Disabled in dev due to test getting stuck
3334
python_flags = ["0.26.0a2"],
3435
tags = [
3536
# TODO(someday): Fix asan failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318

src/workerd/server/workerd-api.c++

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
#include <workerd/util/thread-scopes.h>
4747
#include <workerd/util/use-perfetto-categories.h>
4848

49+
#include <pyodide/generated/pyodide_extra.capnp.h>
50+
4951
#include <kj/compat/http.h>
5052
#include <kj/compat/tls.h>
5153
#include <kj/compat/url.h>
@@ -157,6 +159,7 @@ void writePyodideBundleFileToDisk(const kj::Maybe<kj::Own<const kj::Directory>>&
157159
replacer->commit();
158160
}
159161
}
162+
} // namespace
160163

161164
kj::Maybe<jsg::Bundle::Reader> fetchPyodideBundle(
162165
const api::pyodide::PythonConfig& pyConfig, kj::StringPtr version) {
@@ -213,7 +216,6 @@ kj::Maybe<jsg::Bundle::Reader> fetchPyodideBundle(
213216
KJ_LOG(INFO, "Loaded Pyodide package from internet");
214217
return pyConfig.pyodideBundleManager.getPyodideBundle(version);
215218
}
216-
} // namespace
217219

218220
struct WorkerdApi::Impl final {
219221
kj::Own<CompatibilityFlags::Reader> features;

src/workerd/server/workerd-api.h

+3
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,7 @@ class WorkerdApi final: public Worker::Api {
265265
capnp::List<config::Extension>::Reader extensions) const;
266266
};
267267

268+
kj::Maybe<jsg::Bundle::Reader> fetchPyodideBundle(
269+
const api::pyodide::PythonConfig& pyConfig, kj::StringPtr version);
270+
268271
} // namespace workerd::server

src/workerd/server/workerd.c++

+20-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
// https://opensource.org/licenses/Apache-2.0
44

55
#include "server.h"
6+
#include "workerd-api.h"
67

78
#include <workerd/io/compatibility-date.capnp.h>
9+
#include <workerd/io/compatibility-date.h>
810
#include <workerd/io/supported-compatibility-date.capnp.h>
911
#include <workerd/jsg/setup.h>
1012
#include <workerd/rust/cxx-integration/lib.rs.h>
@@ -15,7 +17,6 @@
1517

1618
#include <fcntl.h>
1719
#include <openssl/rand.h>
18-
#include <pyodide/generated/pyodide_extra.capnp.h>
1920
#include <sys/stat.h>
2021

2122
#include <capnp/dynamic.h>
@@ -807,7 +808,24 @@ class CliMain final: public SchemaFileImpl::ErrorReporter {
807808
context, getVersionString(), "Outputs the package lock file used by Pyodide.");
808809
return builder
809810
.callAfterParsing([]() -> kj::MainBuilder::Validity {
810-
printf("%s\n", PYODIDE_LOCK->cStr());
811+
static const PythonConfig config{
812+
.packageDiskCacheRoot = kj::none,
813+
.pyodideDiskCacheRoot = kj::none,
814+
.createSnapshot = false,
815+
.createBaselineSnapshot = false,
816+
};
817+
818+
capnp::MallocMessageBuilder message;
819+
// TODO(EW-8977): Implement option to specify python worker flags.
820+
auto features = message.getRoot<CompatibilityFlags>();
821+
features.setPythonWorkers(true);
822+
auto pythonRelease = KJ_ASSERT_NONNULL(getPythonSnapshotRelease(features));
823+
auto version = getPythonBundleName(pythonRelease);
824+
KJ_ASSERT_NONNULL(fetchPyodideBundle(config, version), "Failed to get Pyodide bundle");
825+
826+
auto lock = KJ_ASSERT_NONNULL(config.pyodideBundleManager.getPyodideLock(pythonRelease));
827+
828+
printf("%s\n", lock.cStr());
811829
fflush(stdout);
812830
return true;
813831
}).build();

0 commit comments

Comments
 (0)