@@ -81,19 +81,45 @@ 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+
111+ def _capnp_bundle (id , ** _kwds ):
112+ if id == "dev" :
113+ return
114+ name = "pyodide_%s.capnp.bin" % id
115+ copy_file (
116+ name = name + "@rule" ,
117+ src = "@%s//file" % name ,
118+ out = "pyodide-bundle-cache/" + name ,
119+ visibility = ["//visibility:public" ],
120+ )
121+
122+ def _capnp_bundles_file_group ():
97123 # pyodide_dev.capnp.bin represents a custom pyodide version "dev" that is generated
98124 # at build time using the latest contents of the src/pyodide directory.
99125 # This is used to run tests to ensure that they are always run against the latest build of
@@ -104,17 +130,15 @@ def python_test_setup():
104130 out = "pyodide-bundle-cache/pyodide_dev.capnp.bin" ,
105131 visibility = ["//visibility:public" ],
106132 )
107- data = []
108- for x in BUNDLE_VERSION_INFO .values ():
109- if x ["name" ] == "development" :
110- continue
111- data += _snapshot_files (** x )
133+ for info in BUNDLE_VERSION_INFO .values ():
134+ _capnp_bundle (** info )
112135
113- native .filegroup (
114- name = "python_snapshots" ,
115- data = data ,
116- visibility = ["//visibility:public" ],
117- )
136+ def _capnp_rules ():
137+ return [":pyodide_%s.capnp.bin@rule" % info ["id" ] for info in BUNDLE_VERSION_INFO .values ()]
138+
139+ def python_test_setup ():
140+ _capnp_bundles_file_group ()
141+ _snapshot_file_group ()
118142
119143def compute_python_flags (python_flags , skip_python_flags ):
120144 if python_flags == "all" :
@@ -154,7 +178,7 @@ def py_wd_test(
154178 name = directory
155179 elif name == None :
156180 name = src .removesuffix (".wd-test" )
157- data += [ "//src/workerd/server/tests/python:pyodide_dev.capnp.bin@rule" ]
181+ data += _capnp_rules ()
158182 args = args + [
159183 "--pyodide-bundle-disk-cache-dir" ,
160184 "$(location //src/workerd/server/tests/python:pyodide_dev.capnp.bin@rule)/.." ,
0 commit comments