99
1010import yaml
1111
12- from empack .file_packager import split_pack_environment
12+ from empack .pack import pack_env , DEFAULT_CONFIG_PATH
1313from empack .file_patterns import PkgFileFilter , pkg_file_filter_from_yaml
1414
1515import typer
2727
2828PYTHON_VERSION = "3.10"
2929
30- XEUS_PYTHON_VERSION = "0.15.7 "
30+ XEUS_PYTHON_VERSION = "0.15.9 "
3131
3232CHANNELS = [
3333 "https://repo.mamba.pm/emscripten-forge" ,
@@ -199,21 +199,22 @@ def build_and_pack_emscripten_env(
199199 empack_config_is_url = urlparse (empack_config ).scheme in ("http" , "https" )
200200 if empack_config_is_url :
201201 empack_config_content = requests .get (empack_config ).content
202- pack_kwargs ["pkg_file_filter " ] = PkgFileFilter .parse_obj (
202+ pack_kwargs ["file_filters " ] = PkgFileFilter .parse_obj (
203203 yaml .safe_load (empack_config_content )
204204 )
205205 else :
206- pack_kwargs ["pkg_file_filter " ] = pkg_file_filter_from_yaml (
206+ pack_kwargs ["file_filters " ] = pkg_file_filter_from_yaml (
207207 empack_config
208208 )
209+ else :
210+ pack_kwargs ["file_filters" ] = pkg_file_filter_from_yaml (DEFAULT_CONFIG_PATH )
209211
210212 # Pack the environment
211- split_pack_environment (
213+ pack_env (
212214 env_prefix = prefix_path ,
213- outname = "python_data" ,
214- pack_outdir = output_path ,
215- export_name = "globalThis.Module" ,
216- with_export_default_statement = False ,
215+ relocate_prefix = "/" ,
216+ outdir = output_path ,
217+ use_cache = False ,
217218 ** pack_kwargs ,
218219 )
219220
@@ -235,10 +236,12 @@ def build_and_pack_emscripten_env(
235236 worker = worker .replace ("XEUS_KERNEL_FILE" , "'xpython_wasm.js'" )
236237 worker = worker .replace ("LANGUAGE_DATA_FILE" , "'python_data.js'" )
237238 worker = worker .replace ("importScripts(DATA_FILE);" , """
238- importScripts(DATA_FILE);
239- await globalThis.Module.importPackages();
240- await globalThis.Module.init();
241- """ )
239+ await globalThis.Module.bootstrap_from_empack_packed_environment(
240+ `./empack_env_meta.json`, /* packages_json_url */
241+ ".", /* package_tarballs_root_url */
242+ false /* verbose */
243+ );
244+ """ )
242245 with open (Path (output_path ) / "worker.ts" , "w" ) as fobj :
243246 fobj .write (worker )
244247
0 commit comments