mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
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.
This commit is contained in:
parent
afb0d4c56e
commit
9a1d7aabd7
2 changed files with 13 additions and 33 deletions
|
@ -5,12 +5,9 @@
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import site
|
import site
|
||||||
import shutil
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from subprocess import Popen
|
|
||||||
from tempfile import TemporaryFile
|
|
||||||
|
|
||||||
SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__))
|
SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__))
|
||||||
TOP_DIR = os.path.abspath(os.path.join(SCRIPT_PATH, ".."))
|
TOP_DIR = os.path.abspath(os.path.join(SCRIPT_PATH, ".."))
|
||||||
WPT_PATH = os.path.join(TOP_DIR, "tests", "wpt")
|
WPT_PATH = os.path.join(TOP_DIR, "tests", "wpt")
|
||||||
|
@ -103,31 +100,12 @@ def _get_virtualenv_lib_dir():
|
||||||
|
|
||||||
|
|
||||||
def _process_exec(args):
|
def _process_exec(args):
|
||||||
with TemporaryFile() as out:
|
try:
|
||||||
with TemporaryFile() as err:
|
subprocess.check_output(args, stderr=subprocess.STDOUT)
|
||||||
process = Popen(args, stdout=out, stderr=err)
|
except subprocess.CalledProcessError as exception:
|
||||||
process.wait()
|
print(exception.output.decode(sys.stdout.encoding))
|
||||||
if process.returncode:
|
print(f"Process failed with return code: {exception.returncode}")
|
||||||
print('"%s" failed with error code %d:' % ('" "'.join(args), process.returncode))
|
sys.exit(1)
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
def _activate_virtualenv(topdir):
|
def _activate_virtualenv(topdir):
|
||||||
|
@ -137,6 +115,7 @@ def _activate_virtualenv(topdir):
|
||||||
if os.environ.get("VIRTUAL_ENV") != virtualenv_path:
|
if os.environ.get("VIRTUAL_ENV") != virtualenv_path:
|
||||||
venv_script_path = os.path.join(virtualenv_path, _get_virtualenv_script_dir())
|
venv_script_path = os.path.join(virtualenv_path, _get_virtualenv_script_dir())
|
||||||
if not os.path.exists(virtualenv_path):
|
if not os.path.exists(virtualenv_path):
|
||||||
|
print(" * Setting up virtual environment...")
|
||||||
_process_exec([python, "-m", "venv", "--system-site-packages", virtualenv_path])
|
_process_exec([python, "-m", "venv", "--system-site-packages", virtualenv_path])
|
||||||
|
|
||||||
# This general approach is taken from virtualenv's `activate_this.py`.
|
# This general approach is taken from virtualenv's `activate_this.py`.
|
||||||
|
@ -178,6 +157,7 @@ def _activate_virtualenv(topdir):
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
print(f" * Installing Python requirements from {req_path}...")
|
||||||
_process_exec([python, "-m", "pip", "install", "-I", "-r", req_path])
|
_process_exec([python, "-m", "pip", "install", "-I", "-r", req_path])
|
||||||
|
|
||||||
open(marker_path, 'w').close()
|
open(marker_path, 'w').close()
|
||||||
|
|
|
@ -102,8 +102,8 @@ class Base:
|
||||||
if not force and shutil.which("taplo") is not None:
|
if not force and shutil.which("taplo") is not None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if subprocess.call(["cargo", "install", "taplo-cli", "--locked"],
|
print(" * Installing taplo...")
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE) != 0:
|
if subprocess.call(["cargo", "install", "taplo-cli", "--locked"]) != 0:
|
||||||
raise EnvironmentError("Installation of taplo failed.")
|
raise EnvironmentError("Installation of taplo failed.")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -114,8 +114,8 @@ class Base:
|
||||||
env = dict(os.environ)
|
env = dict(os.environ)
|
||||||
env["CARGO_BUILD_RUSTC"] = "rustc"
|
env["CARGO_BUILD_RUSTC"] = "rustc"
|
||||||
|
|
||||||
if subprocess.call(["cargo", "install", "--path", "support/crown"],
|
print(" * Installing crown (the Servo linter)...")
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) != 0:
|
if subprocess.call(["cargo", "install", "--path", "support/crown"], env=env) != 0:
|
||||||
raise EnvironmentError("Installation of crown failed.")
|
raise EnvironmentError("Installation of crown failed.")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue