Back to Microsandbox

Python Examples

examples/python/README.md

0.4.41.6 KB
Original Source

Python Examples

Prerequisites

  • Python 3.10+
  • uv and maturin (uv tool install maturin)
  • msb + libkrunfw installed (bundled in the wheel, or at ~/.microsandbox/)
  • For root-bind and root-block: git submodule update --init --recursive

Setup

Build the Python SDK (one-time):

sh
cd sdk/python
uv sync --group dev
maturin develop --release

Running

From the repo root:

sh
uv run --project sdk/python python examples/python/<example>/main.py

For example:

sh
uv run --project sdk/python python examples/python/root-oci/main.py
uv run --project sdk/python python examples/python/net-basic/main.py
uv run --project sdk/python python examples/python/fs-read-stream/main.py

Examples

ExampleDescription
root-ociOCI image rootfs
root-bindBind-mounted local directory
root-blockqcow2 disk image
rootfs-patchPre-boot filesystem patches
init-handoffHand PID 1 off to systemd
volume-namedNamed volumes shared across sandboxes
volume-diskDisk image volumes (raw / qcow2) at guest paths
snapshot-forkSnapshot a stopped sandbox and boot a fresh one from it
fs-read-streamStreaming file read
metrics-streamStreaming resource metrics
shell-attachInteractive shell attach
net-basicBasic networking
net-dnsDNS filtering
net-policyNetwork policies
net-portsPort publishing
net-secretsSecret injection
net-tlsTLS interception