sagens Python
Python package for managing sagens daemons and BOX workspaces.
What it includes
- Rust bindings for daemon lifecycle helpers and smoke-test server bootstrap
- A synchronous Python client for the
box_apiwebsocket protocol - High-level classes for
Daemon,Box,BoxFs,BoxCheckpoint, andBoxShell pytestsmoke and gated full e2e coverage
Support
- Secure host path: Linux
x86_64, Linuxarm64/aarch64 - macOS
arm64: dev/test only withSAGENS_ISOLATION_MODE=compatandSAGENS_INSECURE_COMPAT=1 - Python versions:
3.11+(pyo3abi3-py311; classifiers for3.11,3.12, and3.13) - Linux secure mode requires
/dev/kvm, delegated cgroup access throughSAGENS_CGROUP_PARENT, and Linux Landlock support - The current backend does not support Windows or secure macOS runtime release paths
Quickstart
Build the host binary, install the package, and run Python inside a BOX:
cargo run --bin xtask -- dev --python-package-root python
python3 -m pip install -e python[test]
python3 - <<'PY'
from tempfile import TemporaryDirectory
from sagens import Daemon
with TemporaryDirectory() as state_dir:
with Daemon.start(state_dir=state_dir) as daemon:
box = daemon.create_box()
# Settings are stop-only, so set them before start or after stop.
box.set("memory_mb", 512)
box.set("fs_size_mib", 1024)
box.set("cpu_cores", 2)
box.set("network_enabled", False)
box.start()
box.fs.write("/workspace/input.txt", b"hello from python\n")
result = box.exec_python(
[
"-c",
(
"from pathlib import Path; "
"text = Path('/workspace/input.txt').read_text(); "
"print(text.strip().upper())"
),
]
)
print(result.stdout.decode().strip())
box.stop()
PY
BOX settings examples
All BOX settings are updated with box.set(...) while the BOX is stopped:
box.set("memory_mb", 512) # Guest RAM in MiB.
box.set("fs_size_mib", 1024) # Persistent workspace disk in MiB.
box.set("cpu_cores", 2)
box.set("network_enabled", True) # Enable network in compat mode only.
box.set("network_enabled", False) # Disable network.
Named Images
See examples/named_images.py for building a local
chromium image and creating two BOXes from it through the SDK.
Local development
Build the host binary and stage it into the package layout:
cargo run --bin xtask -- dev --python-package-root python
Install the package in editable mode:
python3 -m pip install -e python[test]
Run smoke tests:
python3 -m pytest python/tests -q
Run full e2e when runtime assets and env are ready:
SAGENS_RUN_E2E=1 python3 -m pytest python/tests/test_e2e.py -q
Metadata
Release files for sagens 0.0.0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sagens-0.0.0.0.4-cp311-abi3-manylinux_2_39_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.39+ x86-64 | Details |
| sagens-0.0.0.0.4-cp311-abi3-manylinux_2_39_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.39+ ARM64 | Details |
| sagens-0.0.0.0.4-3-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 290.7 MB
Release files / sagens-0.0.0.0.4-cp311-abi3-manylinux_2_39_x86_64.whl
| Download URL | sagens-0.0.0.0.4-cp311-abi3-manylinux_2_39_x86_64.whl |
|---|---|
| Size | 104.0 MB |
| Tags | CPython 3.11 Linux glibc 2.39+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
259131e46814901d0f58cfb7863a6c81f02d867952187c05c53f1f83db10b183
|
|
BLAKE2b-256 checksum How to use checksums |
dd6bf771efc8a191eb1beafa2766ee0dab631e6fd469954487671d05fa636040
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / sagens-0.0.0.0.4-cp311-abi3-manylinux_2_39_aarch64.whl
| Download URL | sagens-0.0.0.0.4-cp311-abi3-manylinux_2_39_aarch64.whl |
|---|---|
| Size | 103.7 MB |
| Tags | CPython 3.11 Linux glibc 2.39+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
48206f4283f17cbfe24eaf1e53806b8aa5950b3ce3c329c3152c41752cfd1194
|
|
BLAKE2b-256 checksum How to use checksums |
ac141cae15eb0398df258ba91e748ae0386b671d09e77e976c6910ef15eb185a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / sagens-0.0.0.0.4-3-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | sagens-0.0.0.0.4-3-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 83.0 MB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d138a542771875dc3039d80603d82994a5f07b82a76f4c34dd7bbb03b9271edd
|
|
BLAKE2b-256 checksum How to use checksums |
c9115a1da6bb6043f394b5e924b60451b8c4220b83dec9a6fa04f556b5c4d098
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for sagens 0.0.0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.