1515from ..get_file_filter import get_file_filter
1616from ..constants import EMSCRIPTEN_HOME
1717
18- # packaging
1918run_app = typer .Typer ()
2019app .add_typer (run_app , name = "run" )
2120
22-
23- # packaging
2421script_app = typer .Typer ()
2522run_app .add_typer (script_app , name = "script" )
2623
2724
28- # constants
29-
30-
3125def parse_mounts (mounts ):
3226 wrong_patter_exception = lambda m : exit_with_err (
3327 f"wrong pattern, must be: <to_mount>:<mount_path> but is `{ m } `"
@@ -54,10 +48,15 @@ def parse_mounts(mounts):
5448
5549conda_env_option = require_option (
5650 * make_names ("conda-env" ),
57- help = "name of the conda environment in which to run the code" ,
51+ help = "host location of the conda environment in which to run the code" ,
5852)
5953script_option = require_option (
60- * make_names ("script" ), help = "path of script INSIDE VIRTUAL FILESYSTEM to run"
54+ * make_names ("script" ), help = "path of script inside the virtual fileystem to run"
55+ )
56+ relocate_prefix_option = typer .Option (
57+ "/" ,
58+ * make_names ("relocate-prefix" ),
59+ help = "location of the conda environment in the virtual file" ,
6160)
6261async_main_option = typer .Option (
6362 False ,
@@ -123,6 +122,7 @@ def browser_main(
123122 script : Path = script_option ,
124123 async_main : bool = async_main_option ,
125124 mounts : List [str ] = mounts_option ,
125+ relocate_prefix : Optional [Path ] = relocate_prefix_option ,
126126 work_dir : Optional [Path ] = work_dir_option ,
127127 pkg_file_filter : Optional [List [Path ]] = pkg_file_filter_option ,
128128 pyjs_dir : Optional [Path ] = pyjs_dir_option ,
@@ -136,6 +136,7 @@ def browser_main(
136136 run_script (
137137 backend_type = BackendType .browser_main ,
138138 conda_env = conda_env ,
139+ relocate_prefix = relocate_prefix ,
139140 script = script ,
140141 async_main = async_main ,
141142 mounts = mounts ,
@@ -155,6 +156,7 @@ def browser_worker(
155156 script : Path = script_option ,
156157 async_main : bool = async_main_option ,
157158 mounts : List [str ] = mounts_option ,
159+ relocate_prefix : Optional [Path ] = relocate_prefix_option ,
158160 work_dir : Optional [Path ] = work_dir_option ,
159161 pkg_file_filter : List [Path ] = pkg_file_filter_option ,
160162 pyjs_dir : Optional [Path ] = pyjs_dir_option ,
@@ -168,6 +170,7 @@ def browser_worker(
168170 run_script (
169171 backend_type = BackendType .browser_worker ,
170172 conda_env = conda_env ,
173+ relocate_prefix = relocate_prefix ,
171174 script = script ,
172175 async_main = async_main ,
173176 mounts = mounts ,
@@ -194,6 +197,7 @@ def node(
194197 script : Path = script_option ,
195198 async_main : bool = async_main_option ,
196199 mounts : List [str ] = mounts_option ,
200+ relocate_prefix : Optional [Path ] = relocate_prefix_option ,
197201 work_dir : Optional [Path ] = work_dir_option ,
198202 pkg_file_filter : List [Path ] = pkg_file_filter_option ,
199203 pyjs_dir : Optional [Path ] = pyjs_dir_option ,
@@ -205,6 +209,7 @@ def node(
205209 run_script (
206210 backend_type = BackendType .node ,
207211 conda_env = conda_env ,
212+ relocate_prefix = relocate_prefix ,
208213 script = script ,
209214 async_main = async_main ,
210215 mounts = mounts ,
@@ -221,6 +226,7 @@ def node(
221226def run_script (
222227 backend_type ,
223228 conda_env ,
229+ relocate_prefix ,
224230 script ,
225231 async_main ,
226232 mounts ,
@@ -244,6 +250,7 @@ def run_script(
244250
245251 run (
246252 conda_env = conda_env ,
253+ relocate_prefix = relocate_prefix ,
247254 backend_type = backend_type ,
248255 script = script ,
249256 async_main = async_main ,
0 commit comments