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.1

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.1
File
virtx-0.1.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
virtx-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details
virtx-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details
virtx-0.1.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details

Total release size: 15.7 MB

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

Download URL virtx-0.1.1-cp310-abi3-win_amd64.whl
Size 3.5 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3daa086a37bacf225551f9448efe75182e782ec4f61b91f28e7d2cdaef2d1265
BLAKE2b-256 checksum
How to use checksums
1a7ea7816aeeb343dc4ecfd37aa078ba9546d5dd738bef9852a3f38525c51804
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.1-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL virtx-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl
Size 4.2 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
f888476c73fbcaeb63b026f15f70b0d1dc6eab5620785e83f6beabdf9a4a2bae
BLAKE2b-256 checksum
How to use checksums
e696a14decff6f923373d06004cc5da29b93e24eef5a9fb5b7bd53c9299c4649
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.1-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL virtx-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl
Size 4.3 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
ae055578eee8d28f3279d333317d96094afc8aea52f2f911363f4283b94c89f2
BLAKE2b-256 checksum
How to use checksums
bbf48da70830e6e4a285e78f18cf52f105d2fdb50f82cd6d8c042ee70c0c46b1
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.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL virtx-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Size 3.8 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3556c11272f921f9aab0f555f6c446c122346ab640a91f65fc213d3445fcd394
BLAKE2b-256 checksum
How to use checksums
01451196664569da78be76d228448d4717e02edf8943da3cb40499e8b79fd0a8
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

This release

0.1.1 This release

4 release files

0.1.0

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