PyObjC Virtualization Framework

12.1 · active · verified Tue Apr 14

pyobjc-framework-virtualization provides Python wrappers for Apple's Virtualization framework on macOS. It is part of the PyObjC project, a bidirectional bridge enabling Python scripts to interact with Objective-C libraries, including macOS Cocoa frameworks. The current version is 12.1, and it maintains an active release cadence, typically aligning with macOS SDK updates and Python version support.

Warnings

Install

Imports

Quickstart

This quickstart checks if the macOS Virtualization framework is supported on the current machine. This is the simplest interaction with the framework without requiring complex setup or specific entitlements. Actual virtual machine creation and execution involve more extensive configuration and may require specific macOS entitlements.

import Virtualization
import os

def check_virtualization_support():
    print(f"Checking macOS Virtualization support...")
    if Virtualization.VZVirtualMachine.isSupported():
        print("\u2705 macOS Virtualization framework is supported on this machine.")
        print("    You can now proceed to create VZVirtualMachineConfiguration objects and manage virtual machines.")
        # Further steps would involve creating a VZVirtualMachineConfiguration,
        # setting up devices, and booting a guest OS, which is beyond a quickstart.
        # Example of a next step (not fully runnable without more config):
        # config = Virtualization.VZVirtualizationMachineConfiguration.alloc().init()
        # if config.validateWithError_(None):
        #     print("    Basic VZVirtualMachineConfiguration object could be initialized.")
    else:
        print("\u274C macOS Virtualization framework is NOT supported on this machine.")
        print("    Requires macOS 11 or later and Apple Silicon or Intel with VT-x.")

if __name__ == "__main__":
    check_virtualization_support()

view raw JSON →