INV / scripts /install_qemu.py
Fred808's picture
Upload 256 files
7a0c684 verified
"""
QEMU Installation Helper Script
This script helps install QEMU and its Python dependencies
"""
import subprocess
import sys
import os
import platform
from pathlib import Path
def check_qemu_installation():
"""Check if QEMU is installed"""
try:
result = subprocess.run(['qemu-system-x86_64', '--version'],
capture_output=True, text=True)
if result.returncode == 0:
print(f"QEMU is installed: {result.stdout.split()[3]}")
return True
except FileNotFoundError:
return False
return False
def install_qemu_windows():
"""Install QEMU on Windows"""
print("Please install QEMU manually on Windows:")
print("1. Download QEMU installer from https://qemu.weilnetz.de/w64/")
print("2. Run the installer")
print("3. Add QEMU to your PATH")
print("\nAfter installation, run this script again to verify the installation")
def install_qemu_linux():
"""Install QEMU on Linux"""
try:
subprocess.run(['sudo', 'apt-get', 'update'], check=True)
subprocess.run(['sudo', 'apt-get', 'install', '-y',
'qemu-system-x86',
'qemu-utils',
'qemu-system-common',
'libvirt-dev'], check=True)
except subprocess.CalledProcessError as e:
print(f"Error installing QEMU: {e}")
sys.exit(1)
def install_python_dependencies():
"""Install Python dependencies"""
requirements_path = Path(__file__).parent / 'requirements.txt'
try:
subprocess.run([sys.executable, '-m', 'pip', 'install', '-r',
str(requirements_path)], check=True)
print("Python dependencies installed successfully")
except subprocess.CalledProcessError as e:
print(f"Error installing Python dependencies: {e}")
sys.exit(1)
def main():
"""Main installation function"""
system = platform.system().lower()
print("Checking QEMU installation...")
if not check_qemu_installation():
print("QEMU is not installed")
if system == 'windows':
install_qemu_windows()
elif system == 'linux':
install_qemu_linux()
else:
print(f"Unsupported system: {system}")
sys.exit(1)
print("\nInstalling Python dependencies...")
install_python_dependencies()
print("\nVerifying installation...")
if check_qemu_installation():
print("QEMU installation verified successfully")
else:
print("QEMU installation verification failed")
sys.exit(1)
if __name__ == '__main__':
main()