@@ -81,19 +81,44 @@ def _snapshot_file(snapshot):
8181 return [":" + snapshot ]
8282
8383def _snapshot_files (
84+ name ,
8485 baseline_snapshot = None ,
8586 numpy_snapshot = None ,
8687 fastapi_snapshot = None ,
8788 dedicated_fastapi_snapshot = None ,
8889 ** _kwds ):
90+ if name == "development" :
91+ return []
8992 result = []
9093 result += _snapshot_file (baseline_snapshot )
9194 result += _snapshot_file (numpy_snapshot )
9295 result += _snapshot_file (fastapi_snapshot )
9396 result += _snapshot_file (dedicated_fastapi_snapshot )
9497 return result
9598
96- def python_test_setup ():
99+ def _snapshot_file_group ():
100+ snapshots = []
101+ for x in BUNDLE_VERSION_INFO .values ():
102+ snapshots += _snapshot_files (** x )
103+
104+ native .filegroup (
105+ name = "python_snapshots" ,
106+ data = snapshots ,
107+ visibility = ["//visibility:public" ],
108+ )
109+
110+ def _capnp_bundle (id , ** _kwds ):
111+ if id == "dev" :
112+ return
113+ name = "pyodide_%s.capnp.bin" % id
114+ copy_file (
115+ name = name + "@rule" ,
116+ src = "@%s//file" % name ,
117+ out = "pyodide-bundle-cache/" + name ,
118+ visibility = ["//visibility:public" ],
119+ )
120+
121+ def _capnp_bundles_file_group ():
97122 # pyodide_dev.capnp.bin represents a custom pyodide version "dev" that is generated
98123 # at build time using the latest contents of the src/pyodide directory.
99124 # This is used to run tests to ensure that they are always run against the latest build of
@@ -104,17 +129,15 @@ def python_test_setup():
104129 out = "pyodide-bundle-cache/pyodide_dev.capnp.bin" ,
105130 visibility = ["//visibility:public" ],
106131 )
107- data = []
108- for x in BUNDLE_VERSION_INFO .values ():
109- if x ["name" ] == "development" :
110- continue
111- data += _snapshot_files (** x )
132+ for info in BUNDLE_VERSION_INFO .values ():
133+ _capnp_bundle (** info )
112134
113- native .filegroup (
114- name = "python_snapshots" ,
115- data = data ,
116- visibility = ["//visibility:public" ],
117- )
135+ def _capnp_rules ():
136+ return ["//src/workerd/server/tests/python:pyodide_%s.capnp.bin@rule" % info ["id" ] for info in BUNDLE_VERSION_INFO .values ()]
137+
138+ def python_test_setup ():
139+ _capnp_bundles_file_group ()
140+ _snapshot_file_group ()
118141
119142def compute_python_flags (python_flags , skip_python_flags ):
120143 if python_flags == "all" :
@@ -154,7 +177,7 @@ def py_wd_test(
154177 name = directory
155178 elif name == None :
156179 name = src .removesuffix (".wd-test" )
157- data += [ "//src/workerd/server/tests/python:pyodide_dev.capnp.bin@rule" ]
180+ data += _capnp_rules ()
158181 args = args + [
159182 "--pyodide-bundle-disk-cache-dir" ,
160183 "$(location //src/workerd/server/tests/python:pyodide_dev.capnp.bin@rule)/.." ,
0 commit comments