From 9a1d7aabd71fe82c9420abdc33a6a9ba0f8eac52 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Fri, 5 Jan 2024 12:14:17 +0100 Subject: bootstrap: Adding more output when installing dependencies (#31003) It's often the case (especially with the taplo installation and on Windows) that bootstrap is doing lots of stuff in the background for a long amount of time. Without output it's hard to tell what exactly is going on. This change adds more output to this process as well as removing some Pythong 2.x era code. --- python/mach_bootstrap.py | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) (limited to 'python/mach_bootstrap.py') diff --git a/python/mach_bootstrap.py b/python/mach_bootstrap.py index 6b638d8e905..9e4fcd3967a 100644 --- a/python/mach_bootstrap.py +++ b/python/mach_bootstrap.py @@ -5,12 +5,9 @@ import os import platform import site -import shutil +import subprocess import sys -from subprocess import Popen -from tempfile import TemporaryFile - SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__)) TOP_DIR = os.path.abspath(os.path.join(SCRIPT_PATH, "..")) WPT_PATH = os.path.join(TOP_DIR, "tests", "wpt") @@ -103,31 +100,12 @@ def _get_virtualenv_lib_dir(): def _process_exec(args): - with TemporaryFile() as out: - with TemporaryFile() as err: - process = Popen(args, stdout=out, stderr=err) - process.wait() - if process.returncode: - print('"%s" failed with error code %d:' % ('" "'.join(args), process.returncode)) - - if sys.version_info >= (3, 0): - stdout = sys.stdout.buffer - else: - stdout = sys.stdout - - print('Output:') - out.seek(0) - stdout.flush() - shutil.copyfileobj(out, stdout) - stdout.flush() - - print('Error:') - err.seek(0) - stdout.flush() - shutil.copyfileobj(err, stdout) - stdout.flush() - - sys.exit(1) + try: + subprocess.check_output(args, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as exception: + print(exception.output.decode(sys.stdout.encoding)) + print(f"Process failed with return code: {exception.returncode}") + sys.exit(1) def _activate_virtualenv(topdir): @@ -137,6 +115,7 @@ def _activate_virtualenv(topdir): if os.environ.get("VIRTUAL_ENV") != virtualenv_path: venv_script_path = os.path.join(virtualenv_path, _get_virtualenv_script_dir()) if not os.path.exists(virtualenv_path): + print(" * Setting up virtual environment...") _process_exec([python, "-m", "venv", "--system-site-packages", virtualenv_path]) # This general approach is taken from virtualenv's `activate_this.py`. @@ -178,6 +157,7 @@ def _activate_virtualenv(topdir): except OSError: pass + print(f" * Installing Python requirements from {req_path}...") _process_exec([python, "-m", "pip", "install", "-I", "-r", req_path]) open(marker_path, 'w').close() -- cgit v1.2.3