2 months ago
Wed Feb 5, 2025 12:28pm PST
Show HN: OSS Python Framework for Running macOS and Linux VMs on Apple Silicon
Building on the momentum of lume, we’re excited to share pylume, a new Python library that makes it easier to manage macOS and Linux virtual machines (VMs) on Apple Silicon directly from your Python code.

pylume extends lume's command-line functionality to Python, giving developers the ability to integrate VM management into their Python scripts or applications.

Why pylume?

While lume makes managing VMs via the command line simple, pylume brings those features to Python, allowing developers to control VMs directly from their code. Here’s why pylume might be useful:

• Native Python API: Manage VMs directly with Python code. For example:

      python
    import asyncio
    from pylume import PyLume, ImageRef, VMRunOpts
    
    async def main():
        async with PyLume() as pylume:
            # Pull an image
            image = ImageRef("macos-sequoia-xcode", "latest", "ghcr.io", "trycua")
            await pylume.pull_image(image, "lume-vm")
    
            # Run the VM
            await pylume.run_vm("lume-vm")
    
            # Get VM details
            vm_details = await pylume.get_vm("lume-vm")
            print("VM Details:", vm_details)
    
            # Stop the VM
            await pylume.stop_vm("lume-vm")
    
    if __name__ == '__main__':
        asyncio.run(main())
      
    
• Supports macOS & Linux VMs: Quickly set up prebuilt images from any Github registries with minimal setup time.

• Configurability: Adjust VM settings like networking, storage, and more, directly from Python. • One-liner VM Creation: Launch VMs in a single line of code, just like you would with Lume’s CLI.

Installation:

pip install pylume

Why Python?

• Automation: Python is great for automation, and with libraries like pyautogui for UI automation, integrating VM management into your workflows allows for testing and automation across different OS environments without needing physical machines.

• CI/CD Integration: Pylume can be easily added to CI/CD pipelines to automate testing of software across different operating systems or versions on Apple Silicon.

• Testing & Development: Quickly set up isolated environments for testing or development, which is particularly useful for cross-platform development or system-level testing.

Feedback & Future Directions:

We’d love to hear how you're using pylume! Here’s what we’re working on next:

• Enhanced Automation: Adding more tools to simplify and automate complex VM workflows.

• More Prebuilt Images: Expanding support for additional OS images and offering pre-built customizations for specific use cases.

Links:

• Pylume GitHub Repo: https://github.com/trycua/pylume

• Lume CLI GitHub Repo: https://github.com/trycua/lume

We look forward to your feedback, suggestions, or any issues you come across!

read article
comments:
add comment
loading comments...