Skip to content

Commit

Permalink
Auto merge of #7678 - AnthonyBroadCrawford:improved-error-messaging-m…
Browse files Browse the repository at this point in the history
…ach-bootstrap, r=frewsxcv

#7630 Adding better error messaging in mach bootstrap for missing virtualenv/pip dependencies 

This PR is in reference to #7630 

I've added a simple try catch around our use of subprocess.check_all when trying to invoke and use python's 

- virtualenv 
- pip

Upon failure, I use sys.exit with an error message for the user.  Exit seemed appropriate as anything beneath those dependencies will fail to execute and result in a non friendly error message

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7678)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Sep 21, 2015
2 parents 4dc986b + 2e0e228 commit a6208f0
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions python/mach_bootstrap.py
Expand Up @@ -84,7 +84,14 @@ def _activate_virtualenv(topdir):

if not os.path.exists(virtualenv_path):
virtualenv = _get_exec("virtualenv2", "virtualenv")
subprocess.check_call([virtualenv, "-p", python, virtualenv_path])

try:
subprocess.check_call([virtualenv, "-p", python, virtualenv_path])
except subprocess.CalledProcessError:
sys.exit("Python virtualenv failed to execute properly.")
except OSError:
sys.exit("Please install virtualenv "
"and ensure permissions prior to running mach.")

activate_path = os.path.join(virtualenv_path, "bin", "activate_this.py")
execfile(activate_path, dict(__file__=activate_path))
Expand All @@ -109,7 +116,15 @@ def _activate_virtualenv(topdir):
continue
except OSError:
open(marker_path, 'w').close()
subprocess.check_call(["pip", "install", "-q", "-r", req_path])

try:
subprocess.check_call(["pip", "install", "-q", "-r", req_path])
except subprocess.CalledProcessError:
sys.exit("Pip failed to execute properly.")
except OSError:
sys.exit("Pip not found. Please install pip and verify permissions"
" prior to running mach.")

os.utime(marker_path, None)


Expand Down

0 comments on commit a6208f0

Please sign in to comment.