11from .backend .backend import BackendType , get_backend_type_family , get_backend_cls
2- from .constants import EXPORT_NAME_SUFFIX
3- from .js_global_object import js_global_object
42from .work_dir_context import work_dir_context
53from .get_cache_dir import get_cache_dir
64
1412import os
1513import shutil
1614import json
17- import sys
18-
19- def pack_mounts (mounts , host_work_dir , backend_type ):
2015
2116
17+ def pack_mounts (mounts , host_work_dir , backend_type ):
2218 mount_js_files = []
2319 for mount_index , (host_path , em_path ) in enumerate (mounts ):
2420 mount_filename = f"mount_{ mount_index } .tar.gz"
2521 mount_js_files .append (mount_filename )
2622 if host_path .is_dir ():
27- pack_directory (host_dir = host_path ,mount_dir = em_path ,outname = mount_filename ,outdir = host_work_dir , compresslevel = 1 )
23+ pack_directory (
24+ host_dir = host_path ,
25+ mount_dir = em_path ,
26+ outname = mount_filename ,
27+ outdir = host_work_dir ,
28+ compresslevel = 1 ,
29+ )
2830
2931 elif host_path .is_file ():
3032 raise RuntimeError ("packing files is not yet supported" )
@@ -36,7 +38,6 @@ def pack_mounts(mounts, host_work_dir, backend_type):
3638 json .dump (mount_js_files , f , indent = 4 )
3739
3840
39-
4041def conda_env_to_cache_name (conda_env , backend_type ):
4142 env_name = str (conda_env ).replace (os .path .sep , "_" )
4243 folder_name = (
@@ -94,7 +95,7 @@ def run(
9495 relocate_prefix = str (relocate_prefix )
9596 if host_work_dir is not None :
9697 host_work_dir = Path (host_work_dir )
97-
98+
9899 if pkg_file_filter is None :
99100 pkg_file_filter = pkg_file_filter_from_yaml (EMPACK_DEFAULT_CONFIG_PATH )
100101
@@ -106,7 +107,6 @@ def run(
106107
107108 # create a temporary host work directory
108109 with host_work_dir_context (host_work_dir ) as host_work_dir :
109-
110110 # copy pyjs-runtime to host-work-dir
111111 copy_pyjs (
112112 conda_env = conda_env ,
@@ -116,16 +116,18 @@ def run(
116116 )
117117
118118 # pack the environment itself
119- pack_env (env_prefix = conda_env ,
120- relocate_prefix = relocate_prefix ,
121- file_filters = pkg_file_filter ,
122- use_cache = use_cache ,
123- cache_dir = cache_dir ,
124- outdir = host_work_dir ,
125- compresslevel = 9 )
119+ pack_env (
120+ env_prefix = conda_env ,
121+ relocate_prefix = relocate_prefix ,
122+ file_filters = pkg_file_filter ,
123+ use_cache = use_cache ,
124+ cache_dir = cache_dir ,
125+ outdir = host_work_dir ,
126+ compresslevel = 9 ,
127+ )
126128
127129 # pack all the mounts
128- mount_js_files = pack_mounts (
130+ pack_mounts (
129131 mounts = mounts ,
130132 backend_type = backend_type ,
131133 host_work_dir = host_work_dir ,
@@ -142,4 +144,3 @@ def run(
142144
143145 # run
144146 backend .run ()
145-
0 commit comments