Skip to content

Commit

Permalink
download reactor on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronFriel committed Sep 9, 2024
1 parent acbf6db commit 75b6c64
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions controllers/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./wasi_snapshot_preview1.reactor.wasm
14 changes: 13 additions & 1 deletion py/pyaici/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import os
import argparse
import requests

from . import rest, jssrc
from . import add_cli_args, runner_from_cli
Expand All @@ -14,6 +15,17 @@ def cli_error(msg: str):
print("Error: " + msg)
sys.exit(1)

def acquire_reactor_adaptor():
if os.path.exists("controllers/wasi_snapshot_preview1.reactor.wasm"):
return

print("Downloading reactor adaptor...")
url = "https://github.com/bytecodealliance/wasmtime/releases/download/dev/wasi_snapshot_preview1.reactor.wasm"
response = requests.get(url)
with open("controllers/wasi_snapshot_preview1.reactor.wasm", "wb") as f:
f.write(response.content)

return os.path.abspath("controllers/wasi_snapshot_preview1.reactor.wasm")

def build_rust(folder: str, features: List[str] = []):
bin_file = ""
Expand Down Expand Up @@ -66,7 +78,7 @@ def build_rust(folder: str, features: List[str] = []):
+ ".component.wasm"
)

reactor_path = "controllers/wasi_snapshot_preview1.reactor.wasm"
reactor_path = acquire_reactor_adaptor()

# remove file first, so we're sure it's rebuilt
try:
Expand Down

0 comments on commit 75b6c64

Please sign in to comment.