@@ -44,38 +44,6 @@ filegroup(
4444
4545SNAPSHOT_R2 = "https://pyodide-capnp-bin.edgeworker.net/"
4646
47- def _snapshot_http_file (bundle_name , folder , snapshot , integrity , hash , r2_base = SNAPSHOT_R2 ):
48- if not snapshot :
49- return
50- if not integrity :
51- fail ("Snapshot %s from bundle %s has missing integrity" % (snapshot , bundle_name ))
52- if folder == "baseline-snapshot/" :
53- key = hash
54- else :
55- key = snapshot
56- http_file (
57- name = "pyodide-snapshot-" + snapshot ,
58- integrity = integrity ,
59- url = r2_base + folder + key ,
60- )
61-
62- def _snapshot_http_files (
63- name ,
64- baseline_snapshot = None ,
65- baseline_snapshot_hash = None ,
66- baseline_snapshot_integrity = None ,
67- numpy_snapshot = None ,
68- numpy_snapshot_integrity = None ,
69- fastapi_snapshot = None ,
70- fastapi_snapshot_integrity = None ,
71- dedicated_fastapi_snapshot = None ,
72- dedicated_fastapi_snapshot_integrity = None ,
73- ** _kwds ):
74- _snapshot_http_file (name , "baseline-snapshot/" , baseline_snapshot , baseline_snapshot_integrity , baseline_snapshot_hash )
75- _snapshot_http_file (name , "test-snapshot/" , numpy_snapshot , numpy_snapshot_integrity , None )
76- _snapshot_http_file (name , "test-snapshot/" , fastapi_snapshot , fastapi_snapshot_integrity , None )
77- _snapshot_http_file (name , "" , dedicated_fastapi_snapshot , dedicated_fastapi_snapshot_integrity , None , VENDOR_R2 )
78-
7947def dep_pyodide ():
8048 for info in PYODIDE_VERSIONS :
8149 _pyodide_core (** info )
@@ -87,10 +55,48 @@ def dep_pyodide():
8755 for info in PYTHON_LOCKFILES :
8856 _pyodide_packages (** info )
8957
58+ # Accumulator to de-duplicate generated http_file rules.
59+ gen_http_file = {}
60+
61+ def _snapshot_http_files (
62+ name ,
63+ baseline_snapshot = None ,
64+ baseline_snapshot_hash = None ,
65+ baseline_snapshot_integrity = None ,
66+ numpy_snapshot = None ,
67+ numpy_snapshot_integrity = None ,
68+ fastapi_snapshot = None ,
69+ fastapi_snapshot_integrity = None ,
70+ dedicated_fastapi_snapshot = None ,
71+ dedicated_fastapi_snapshot_integrity = None ,
72+ ** _kwds ):
73+ def _snapshot_http_file (bundle_name , folder , snapshot , integrity , hash , r2_base = SNAPSHOT_R2 ):
74+ if not snapshot :
75+ return
76+ if not integrity :
77+ fail ("Snapshot %s from bundle %s has missing integrity" % (snapshot , bundle_name ))
78+ if folder == "baseline-snapshot/" :
79+ key = hash
80+ else :
81+ key = snapshot
82+ gen_http_file [snapshot ] = struct (
83+ integrity = integrity ,
84+ url = r2_base + folder + key ,
85+ )
86+
87+ _snapshot_http_file (name , "baseline-snapshot/" , baseline_snapshot , baseline_snapshot_integrity , baseline_snapshot_hash )
88+ _snapshot_http_file (name , "test-snapshot/" , numpy_snapshot , numpy_snapshot_integrity , None )
89+ _snapshot_http_file (name , "test-snapshot/" , fastapi_snapshot , fastapi_snapshot_integrity , None )
90+ _snapshot_http_file (name , "" , dedicated_fastapi_snapshot , dedicated_fastapi_snapshot_integrity , None , VENDOR_R2 )
91+
9092 for ver in BUNDLE_VERSION_INFO .values ():
91- if ver ["name" ] == "development" or ver ["name" ] == "0.26.0a2" :
92- continue # development is a copy of earlier bundle snapshots
9393 _snapshot_http_files (** ver )
94+ for snapshot , info in gen_http_file .items ():
95+ http_file (
96+ name = "pyodide-snapshot-" + snapshot ,
97+ integrity = info .integrity ,
98+ url = info .url ,
99+ )
94100
95101def _impl (module_ctx ):
96102 dep_pyodide ()
0 commit comments