91e75e620b
CI: cua-driver distro-compat matrix / debian:12 (glibc 2.36) (push) Has been cancelled
CI: SPDX Headers / Check SPDX headers (warn-only) (push) Has been cancelled
CD: Docs MCP Server / build (linux/amd64) (push) Has been cancelled
CD: Docs MCP Server / build (linux/arm64) (push) Has been cancelled
CD: Docs MCP Server / merge (push) Has been cancelled
CI: cua-driver distro-compat matrix / Resolve release version (push) Has been cancelled
CI: cua-driver distro-compat matrix / fedora:41 (glibc 2.40) (push) Has been cancelled
CI: cua-driver distro-compat matrix / rockylinux:9 (glibc 2.34) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:22.04 (glibc 2.35) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:24.04 (glibc 2.39) (push) Has been cancelled
CI: cua-driver distro-compat matrix / Distro compat summary (push) Has been cancelled
CI: Rust Linux unit / Rust Linux unit and compile (push) Has been cancelled
CI: Rust Windows unit / Rust Windows unit and compile (push) Has been cancelled
CI: Nix Linux Rust source / Nix / compositor build (push) Has been cancelled
CI: Nix Linux Rust source / Nix / driver package (push) Has been cancelled
CI: Nix Linux Rust source / Nix / Rust unit tests (push) Has been cancelled
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
"""Run a cloud macOS VM in Python with the Cua Sandbox SDK.
|
|
|
|
async with Sandbox.ephemeral(Image.macos("26")) as sb:
|
|
await sb.shell.run("sw_vers")
|
|
screenshot = await sb.screenshot()
|
|
|
|
Sandbox.ephemeral() without local=True provisions a macOS VM on the Cua cloud.
|
|
Requires CUA_API_KEY environment variable. Works on any host OS — no Mac needed.
|
|
|
|
Contrast:
|
|
Image.macos("26") + local=False -> Cua cloud macOS VM (this file)
|
|
Image.macos("26") + local=True -> Lume VM, macOS host only
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import os
|
|
|
|
import pytest
|
|
from cua_sandbox import Image, Sandbox
|
|
|
|
pytestmark = pytest.mark.asyncio
|
|
|
|
|
|
def _has_cua_api_key() -> bool:
|
|
return bool(os.environ.get("CUA_API_KEY"))
|
|
|
|
|
|
@pytest.mark.skipif(not _has_cua_api_key(), reason="CUA_API_KEY not set")
|
|
async def test_macos_cloud_vm():
|
|
async with Sandbox.ephemeral(
|
|
Image.macos("26"),
|
|
name="example-macos-cloud-vm",
|
|
) as sb:
|
|
result = await sb.shell.run("sw_vers")
|
|
assert result.success
|
|
assert "macOS" in result.stdout or "Mac" in result.stdout
|
|
|
|
screenshot = await sb.screenshot()
|
|
assert screenshot[:4] == b"\x89PNG"
|
|
|
|
|
|
async def main():
|
|
async with Sandbox.ephemeral(
|
|
Image.macos("26"),
|
|
name="example-macos-cloud-vm",
|
|
) as sb:
|
|
result = await sb.shell.run("sw_vers")
|
|
print(f"sw_vers: {result.stdout.strip()}")
|
|
|
|
screenshot = await sb.screenshot()
|
|
print(f"Screenshot: {len(screenshot)} bytes")
|
|
with open("/tmp/macos_cloud_vm.png", "wb") as f:
|
|
f.write(screenshot)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|