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() diff --git a/python/servo/platform/base.py b/python/servo/platform/base.py index eee42428e56..39d7ae5f293 100644 --- a/python/servo/platform/base.py +++ b/python/servo/platform/base.py @@ -102,8 +102,8 @@ class Base: if not force and shutil.which("taplo") is not None: return False - if subprocess.call(["cargo", "install", "taplo-cli", "--locked"], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) != 0: + print(" * Installing taplo...") + if subprocess.call(["cargo", "install", "taplo-cli", "--locked"]) != 0: raise EnvironmentError("Installation of taplo failed.") return True @@ -114,8 +114,8 @@ class Base: env = dict(os.environ) env["CARGO_BUILD_RUSTC"] = "rustc" - if subprocess.call(["cargo", "install", "--path", "support/crown"], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) != 0: + print(" * Installing crown (the Servo linter)...") + if subprocess.call(["cargo", "install", "--path", "support/crown"], env=env) != 0: raise EnvironmentError("Installation of crown failed.") return True