This repository was archived by the owner on May 14, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,29 @@ npm run build
2828node examples/napi.js
2929```
3030
31+ ### Python
32+
33+
34+ > ** Setup (one-time):**
35+ > ``` bash
36+ > pipx install maturin # to install, see: https://pipx.pypa.io/stable/
37+ >
38+ > pipx ensurepath # adds ~/.local/bin to PATH
39+ >
40+ > # Restart your terminal or run: export PATH="$HOME/.local/bin:$PATH"
41+ > ` ` `
42+
43+ Run from Python:
44+ ` ` ` bash
45+ # Create and activate venv
46+ python3 -m venv .venv
47+ source .venv/bin/activate
48+
49+ # Build the Rust extension and install it in venv then run example
50+ maturin develop --features python
51+ python examples/python_sdk_example.py
52+ ```
53+
3154### C & C++ Programs
3255
3356For compiled languages, you'll need to compile first, then run.
@@ -120,6 +143,26 @@ if (result.success) {
120143}
121144```
122145
146+ ### Python
147+
148+ ``` python
149+ import asyncio
150+ from hyperlight_nanvix import NanvixSandbox, SandboxConfig
151+
152+ async def main ():
153+ config = SandboxConfig(
154+ log_directory = " /tmp/hyperlight-nanvix" ,
155+ tmp_directory = " /tmp/hyperlight-nanvix"
156+ )
157+ sandbox = NanvixSandbox(config)
158+
159+ result = await sandbox.run(' guest-examples/hello.js' )
160+ if result.success:
161+ print (' Execution completed' )
162+
163+ asyncio.run(main())
164+ ```
165+
123166To embed in your own project:
124167
125168``` bash
Original file line number Diff line number Diff line change 1+ import asyncio
2+ from hyperlight_nanvix import NanvixSandbox
3+
4+ async def main ():
5+ print ("Running guest-examples/hello.js..." )
6+
7+ try :
8+ sandbox = NanvixSandbox ()
9+ result = await sandbox .run ("guest-examples/hello.js" )
10+
11+ if result .success :
12+ print ("Workload completed successfully!" )
13+ else :
14+ print (f"Error: { result .error } " )
15+ exit (1 )
16+ except Exception as error :
17+ print (f"Error: { error } " )
18+ exit (1 )
19+
20+ asyncio .run (main ())
You can’t perform that action at this time.
0 commit comments