From ebf021c01d9d4e7183304ab0d9c9c6da685e7287 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 19 Dec 2024 11:41:36 +0100 Subject: [PATCH] Add compatibility date for Pyodide 0.27.1 --- src/workerd/io/compatibility-date.capnp | 7 ++++++ src/workerd/server/tests/python/BUILD.bazel | 23 ++++++++++++++++++- .../server/tests/python/import_tests.bzl | 3 ++- .../server/tests/python/py_wd_test.bzl | 6 +++-- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/workerd/io/compatibility-date.capnp b/src/workerd/io/compatibility-date.capnp index 3572bf2aa5e..4342107465c 100644 --- a/src/workerd/io/compatibility-date.capnp +++ b/src/workerd/io/compatibility-date.capnp @@ -679,4 +679,11 @@ struct CompatibilityFlags @0x8f8c1b68151b6cef { $compatDisableFlag("cache_no_cache_disabled") $experimental; # Enables the use of cache: no-cache in the fetch api. + + pythonWorkers20250116 @71 :Bool + $compatEnableFlag("python_workers_20250116") + $experimental + $pythonSnapshotRelease(pyodide = "0.27.1", pyodideRevision = "2025-01-16", + packages = "2024-12-18", backport = 0, + baselineSnapshotHash = "TODO"); } diff --git a/src/workerd/server/tests/python/BUILD.bazel b/src/workerd/server/tests/python/BUILD.bazel index 450650b77f7..bfa7eb38bbd 100644 --- a/src/workerd/server/tests/python/BUILD.bazel +++ b/src/workerd/server/tests/python/BUILD.bazel @@ -38,4 +38,25 @@ py_wd_test( ], ) -gen_import_tests(PYODIDE_IMPORTS_TO_TEST) +gen_import_tests( + PYODIDE_IMPORTS_TO_TEST, + # TODO: Micropip version mismatch for 0.27.0 + pkg_python_versions = { + "micropip": [ + "0.26.0a2", + "development", + ], + "langchain-core": [ + "0.26.0a2", + "development", + ], + "langchain_openai": [ + "0.26.0a2", + "development", + ], + "langsmith": [ + "0.26.0a2", + "development", + ], + }, +) diff --git a/src/workerd/server/tests/python/import_tests.bzl b/src/workerd/server/tests/python/import_tests.bzl index 5409cd1d624..d17f30c7899 100644 --- a/src/workerd/server/tests/python/import_tests.bzl +++ b/src/workerd/server/tests/python/import_tests.bzl @@ -32,7 +32,7 @@ def generate_wd_test_file(requirement): return WD_FILE_TEMPLATE.format(requirement, requirement) # to_test is a dictionary from library name to list of imports -def gen_import_tests(to_test): +def gen_import_tests(to_test, pkg_python_versions = {}): for lib in to_test.keys(): prefix = "import/" + lib worker_py_fname = prefix + "/worker.py" @@ -52,6 +52,7 @@ def gen_import_tests(to_test): name = prefix, directory = lib, src = wd_test_fname, + python_flags = pkg_python_versions.get(lib, "all"), args = ["--experimental", "--pyodide-package-disk-cache-dir", "../all_pyodide_wheels"], data = [worker_py_fname, "@all_pyodide_wheels//:whls"], size = "enormous", diff --git a/src/workerd/server/tests/python/py_wd_test.bzl b/src/workerd/server/tests/python/py_wd_test.bzl index c646724dc5f..572979b7ebe 100644 --- a/src/workerd/server/tests/python/py_wd_test.bzl +++ b/src/workerd/server/tests/python/py_wd_test.bzl @@ -2,7 +2,8 @@ load("@bazel_skylib//rules:expand_template.bzl", "expand_template") load("//:build/wd_test.bzl", "wd_test") FEATURE_FLAGS = { - "0.26.0a2": ["python_workers"], + "0.26.0a2": [], + "0.27.1": ["python_workers_20250116"], "development": ["python_workers_development", "python_external_packages"], } @@ -37,7 +38,8 @@ def py_wd_test( name_flag = name + "_" + python_flag templated_src = name_flag.replace("/", "-") + "@template" templated_src = "/".join(src.split("/")[:-1] + [templated_src]) - feature_flags_txt = ",".join(['"{}"'.format(flag) for flag in FEATURE_FLAGS[python_flag]]) + flags = FEATURE_FLAGS[python_flag] + ["python_workers"] + feature_flags_txt = ",".join(['"{}"'.format(flag) for flag in flags]) expand_template( name = name_flag + "@rule", out = templated_src,