From edf2b7fc138f5dc56636afda373305a2f2a5ff62 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 12 Jul 2024 17:36:36 +0100 Subject: [PATCH] Captured pip install output line by line, printing each line with a carriage return to overwrite, and displaying full output on failure. --- aider/utils.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/aider/utils.py b/aider/utils.py index d075eb28d..78df252bd 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -189,9 +189,26 @@ def pip_install(args): ] cmd += args + process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1, universal_newlines=True) + output = [] + try: - res = subprocess.run(cmd) + for line in process.stdout: + line = line.strip() + print(f"\r{line}", end='', flush=True) + output.append(line) + + return_code = process.wait() + + if return_code != 0: + print("\nInstallation failed. Full output:") + for line in output: + print(line) + return False + + print() # Print a newline after successful installation + return True + except subprocess.CalledProcessError as e: - print(f"Error running pip download: {e}") - - return res.returncode == 0 + print(f"\nError running pip install: {e}") + return False