Skip to main content

virtx for Python

Python bindings for virtx: the same ConsoleClient, ImageClient, Recipe, Directory and host mount as the Rust crate, with every call that waits as an awaitable.

from virtx import ConsoleClient, Directory, HostMount, Recipe

mount = HostMount(Directory().with_file("SKILL.md", "..."), "/tmp/skill")

async with await (
    ConsoleClient.builder()
    .cmd(["virtx-uvm"])
    .image(Recipe("python:3.12-slim-trixie").step("pip install duckdb"))
    .mount_readonly(mount, "/skills/example")
    .mount("./artifacts", "/artifacts")
    .network(False)
    .vcpus(2)
    .memory_mib(2048)
    .build()
) as console:
    result = await console.exec(["sh", "-c", "ls /skills/example"], timeout_ms=10_000)
    print(result.code, result.stdout.decode())

Without .cmd(..) a console runs virtx-uvm from the stdio server directory ($VIRTX_STDIO_SERVER_PATH, or ~/.cache/virtx/bin).

An image can also be built ahead of the session that runs on it, and then named by its ref or its digest:

from virtx import ImageClient, ImageSource, Recipe

async with await ImageClient.try_new() as images:
    built = await images.build(Recipe("alpine:3.20").step("apk add jq"), "myimg:latest")
    print(built.reference, built.digest)

    for image in await images.list():
        print(image.digest, image.refs)

console = await ConsoleClient.builder().image(ImageSource.digest(built.digest)).build()

Building

The extension is built with maturin. The mount feature is on by default and needs the host's FUSE provider, as the crate does — see the top-level README.

cd bindings/python
uv sync                        # makes .venv and installs the dev group
uv run maturin develop         # builds the extension into it
uv run pytest

uv run maturin build --release makes a wheel. The crate's other features pass through: maturin develop --features s3,notion.

The console tests at the end of tests/test_virtx.py need a console server, named by $VIRTX_CONSOLE; without one they are skipped.

Metadata

Release files for virtx 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for virtx 0.1.0
File
virtx-0.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
virtx-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
virtx-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
virtx-0.1.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details

Total release size: 15.6 MB

Release files / virtx-0.1.0-cp310-abi3-win_amd64.whl

Download URL virtx-0.1.0-cp310-abi3-win_amd64.whl
Size 3.5 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
507d5cc7059bb9e2ab0bfc75fd3277949d48ad1f634f635a96acf161af587fb0
BLAKE2b-256 checksum
How to use checksums
d430268e7c4ceb6c366b62c7ec89791586947c5f91f580031c0aa756cced446f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / virtx-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL virtx-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.2 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
bd4a90e3168820cc97fb6c4087a99cf95278fbfc5ab4e62cd22621192d5cd0d0
BLAKE2b-256 checksum
How to use checksums
ce8477bf779f7dc5f26533129739cdfaf4b1915fc79030728e0bb3703dbb5887
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / virtx-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL virtx-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 4.3 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
0c426084b193a99bd3a41bdd18f450ed641e1d12acd7121b5ca82254d64ef4c6
BLAKE2b-256 checksum
How to use checksums
745776808fad80795a56ad42cab4feb43d71d496b8ef9e6918633cf2eb1ca937
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / virtx-0.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL virtx-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 3.7 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b8bfc383d81325a019889cf2e1ac0775983eeec487fb638d5ac6cdc866763e90
BLAKE2b-256 checksum
How to use checksums
e39615442fc99e1f1a7e5388b5e2681e99f87ef1c83948e78b33f8af03f54297
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

0.1.1

4 release files

This release

0.1.0 This release

4 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page