-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathpywasm.py
More file actions
executable file
·54 lines (37 loc) · 1.27 KB
/
pywasm.py
File metadata and controls
executable file
·54 lines (37 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import subprocess
import os
import shlex
import sys
from pathlib import Path
from typing import Dict, List, Tuple
import importlib
# shlex.split() splits according to shell quoting rules
RUN_PYWASM = Path(__file__).parent.parent / "tools" / "run-pywasm"
def get_name() -> str:
return "pywasm"
def get_version() -> str:
# ensure no args when version is queried
result = subprocess.run([RUN_PYWASM, "--version"],
encoding="UTF-8", capture_output=True,
check=True)
output = result.stdout.splitlines()[0].split(" ")
return output[1]
def get_wasi_versions() -> List[str]:
return ["wasm32-wasip1"]
def get_wasi_worlds() -> List[str]:
return ["wasi:cli/command"]
def compute_argv(test_path: str,
args_env_dirs: Tuple[List[str], Dict[str, str], List[Tuple[Path, str]]],
proposals: List[str],
wasi_world: str,
wasi_version: str) -> List[str]:
argv = []
argv += [str(RUN_PYWASM)]
args, env, dirs = args_env_dirs
for k, v in env.items():
argv += ["--env", f"{k}={v}"]
for host, guest in dirs:
argv += ["--dir", f"{host}::{guest}"] # noqa: E231
argv += [test_path]
argv += args
return argv