import subprocess import os def run_command(command, cwd=None): """Executes a shell command and prints output""" result = subprocess.run(command, cwd=cwd, text=True, capture_output=True, shell=True) if result.returncode != 0: print(f"Error executing command: {command}") print(result.stderr) else: print(result.stdout) def install_openblas(): # Step 1: Clone the OpenBLAS repository print("Cloning the OpenBLAS repository...") run_command("apt-get install build-essential gfortran") run_command("git clone https://github.com/OpenMathLib/OpenBLAS.git") # Step 2: Change to the OpenBLAS directory os.chdir("OpenBLAS") # Step 3: Build OpenBLAS print("Building OpenBLAS...") run_command("make TARGET=SAPPHIRERAPIDS") # Step 4: Install OpenBLAS print("Installing OpenBLAS...") run_command("make install") if __name__ == "__main__": install_openblas()