servo: Merge #11067 - Mach now shows stderr when a virtualenv or pip call fails (fixes #11055) (from autrilla:mach-errors); r=mbrubeck
authorAdrian Utrilla <adrianutrilla@gmail.com>
Sat, 07 May 2016 13:15:40 -0700
changeset 338740 08829edf19267012a54b32c51dbbee6242394d45
parent 338739 c1e7be02ea4371a119f21742ec3921accbd8d7c7
child 338741 338d9095b5fd57a660c5a7d2b377f280a8b15325
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
servo: Merge #11067 - Mach now shows stderr when a virtualenv or pip call fails (fixes #11055) (from autrilla:mach-errors); r=mbrubeck Source-Repo: https://github.com/servo/servo Source-Revision: c226bf85a9476a7a701a69974dfa0893c0e6bcb5
servo/python/mach_bootstrap.py
--- a/servo/python/mach_bootstrap.py
+++ b/servo/python/mach_bootstrap.py
@@ -101,20 +101,24 @@ def _activate_virtualenv(topdir):
 
     script_dir = _get_virtualenv_script_dir()
     activate_path = os.path.join(virtualenv_path, script_dir, "activate_this.py")
     if not (os.path.exists(virtualenv_path) and os.path.exists(activate_path)):
         virtualenv = _get_exec(*VIRTUALENV_NAMES)
         if virtualenv is None:
             sys.exit("Python virtualenv is not installed. Please install it prior to running mach.")
 
-        try:
-            subprocess.check_call([virtualenv, "-p", python, virtualenv_path])
-        except (subprocess.CalledProcessError, OSError):
-            sys.exit("Python virtualenv failed to execute properly.")
+        process = subprocess.Popen(
+            [virtualenv, "-p", python, virtualenv_path],
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE)
+        process.wait()
+        if process.returncode:
+            sys.exit("Python virtualenv failed to execute properly: {}"
+                     .format(process.communicate()[1]))
 
     execfile(activate_path, dict(__file__=quote(activate_path)))
 
     # TODO: Right now, we iteratively install all the requirements by invoking
     # `pip install` each time. If it were the case that there were conflicting
     # requirements, we wouldn't know about them. Once
     # https://github.com/pypa/pip/issues/988 is addressed, then we can just
     # chain each of the requirements files into the same `pip install` call
@@ -133,20 +137,24 @@ def _activate_virtualenv(topdir):
                 continue
         except OSError:
             pass
 
         pip = _get_exec(*PIP_NAMES)
         if pip is None:
             sys.exit("Python pip is not installed. Please install it prior to running mach.")
 
-        try:
-            subprocess.check_call([pip, "install", "-q", "-r", req_path])
-        except (subprocess.CalledProcessError, OSError):
-            sys.exit("Pip failed to execute properly.")
+        process = subprocess.Popen(
+            [pip, "install", "-q", "-r", req_path],
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE)
+        process.wait()
+        if process.returncode:
+            sys.exit("Pip failed to execute properly: {}"
+                     .format(process.communicate()[1]))
 
         open(marker_path, 'w').close()
 
 
 def bootstrap(topdir):
     topdir = os.path.abspath(topdir)
 
     # We don't support paths with Unicode characters for now