diff --git a/src/workerd/api/pyodide/pyodide.h b/src/workerd/api/pyodide/pyodide.h index fa3d9e56a88..6dde213bb6b 100644 --- a/src/workerd/api/pyodide/pyodide.h +++ b/src/workerd/api/pyodide/pyodide.h @@ -425,7 +425,8 @@ bool hasPythonModules(capnp::List::Reader module template void registerPyodideModules(Registry& registry, auto featureFlags) { // We add `pyodide:` packages here including python-entrypoint-helper.js. - if (!featureFlags.getPythonExternalBundle()) { + if (!featureFlags.getPythonExternalBundle() && + !util::Autogate::isEnabled(util::AutogateKey::PYTHON_EXTERNAL_BUNDLE)) { registry.addBuiltinBundle(PYODIDE_BUNDLE, kj::none); } registry.template addBuiltinModule( @@ -435,7 +436,8 @@ void registerPyodideModules(Registry& registry, auto featureFlags) { kj::Own getInternalPyodideModuleBundle(auto featureFlags) { jsg::modules::ModuleBundle::BuiltinBuilder builder( jsg::modules::ModuleBundle::BuiltinBuilder::Type::BUILTIN_ONLY); - if (!featureFlags.getPythonExternalBundle()) { + if (!featureFlags.getPythonExternalBundle() && + !util::Autogate::isEnabled(util::AutogateKey::PYTHON_EXTERNAL_BUNDLE)) { jsg::modules::ModuleBundle::getBuiltInBundleFromCapnp(builder, PYODIDE_BUNDLE); } return builder.finish(); @@ -444,7 +446,8 @@ kj::Own getInternalPyodideModuleBundle(auto featureF kj::Own getExternalPyodideModuleBundle(auto featureFlags) { jsg::modules::ModuleBundle::BuiltinBuilder builder( jsg::modules::ModuleBundle::BuiltinBuilder::Type::BUILTIN); - if (!featureFlags.getPythonExternalBundle()) { + if (!featureFlags.getPythonExternalBundle() && + !util::Autogate::isEnabled(util::AutogateKey::PYTHON_EXTERNAL_BUNDLE)) { jsg::modules::ModuleBundle::getBuiltInBundleFromCapnp(builder, PYODIDE_BUNDLE); } return builder.finish(); diff --git a/src/workerd/server/workerd-api.c++ b/src/workerd/server/workerd-api.c++ index 1140ae2febf..179c4ddb4f9 100644 --- a/src/workerd/server/workerd-api.c++ +++ b/src/workerd/server/workerd-api.c++ @@ -511,7 +511,8 @@ void WorkerdApi::compileModules(jsg::Lock& lockParam, KJ_REQUIRE(featureFlags.getPythonWorkers(), "The python_workers compatibility flag is required to use Python."); // Inject Pyodide bundle - if (featureFlags.getPythonExternalBundle()) { + if (featureFlags.getPythonExternalBundle() || + util::Autogate::isEnabled(util::AutogateKey::PYTHON_EXTERNAL_BUNDLE)) { auto pythonRelease = KJ_ASSERT_NONNULL(getPythonSnapshotRelease(featureFlags)); auto version = getPythonBundleName(pythonRelease); auto bundle = KJ_ASSERT_NONNULL( diff --git a/src/workerd/util/autogate.c++ b/src/workerd/util/autogate.c++ index 79376ebbf1b..7d994c88697 100644 --- a/src/workerd/util/autogate.c++ +++ b/src/workerd/util/autogate.c++ @@ -17,6 +17,8 @@ kj::StringPtr KJ_STRINGIFY(AutogateKey key) { switch (key) { case AutogateKey::TEST_WORKERD: return "test-workerd"_kj; + case AutogateKey::PYTHON_EXTERNAL_BUNDLE: + return "python-external-bundle"_kj; case AutogateKey::NumOfKeys: KJ_FAIL_ASSERT("NumOfKeys should not be used in getName"); } diff --git a/src/workerd/util/autogate.h b/src/workerd/util/autogate.h index fe934116c10..d4d3b620077 100644 --- a/src/workerd/util/autogate.h +++ b/src/workerd/util/autogate.h @@ -14,6 +14,7 @@ namespace workerd::util { // Workerd-specific list of autogate keys (can also be used in internal repo). enum class AutogateKey { TEST_WORKERD, + PYTHON_EXTERNAL_BUNDLE, NumOfKeys // Reserved for iteration. };