From 0ccd82711dce04be99c84b9f3ef68e832cc43795 Mon Sep 17 00:00:00 2001 From: Alena Volkova Date: Tue, 26 Sep 2017 20:35:21 -0400 Subject: [PATCH 1/3] provision: Give a clear error message when virtualenv is missing. Without this tweak, running the script results in a vague "No such file or directory" error if the virtualenv package is not installed. --- tools/provision | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/provision b/tools/provision index e3917906f..ef43ade0a 100755 --- a/tools/provision +++ b/tools/provision @@ -24,10 +24,18 @@ the Python version this command is executed with.""" venv_dir = os.path.join(base_dir, venv_name) if not os.path.isdir(venv_dir): - if subprocess.call(['virtualenv', '-p', python_interpreter, venv_dir]): - raise OSError("The command `virtualenv -p {} {}` failed. Virtualenv not created!" - .format(python_interpreter, venv_dir)) + try: + return_code = subprocess.call(['virtualenv', '-p', python_interpreter, venv_dir]) + except OSError: + if subprocess.call(['which', 'virtualenv']): + print("{red}Please install the virtualenv package and try again.{end_format}" + .format(red='\033[91m', end_format='\033[0m')) + sys.exit(1) + raise else: + if return_code: + raise OSError("The command `virtualenv -p {} {}` failed. Virtualenv not created!" + .format(python_interpreter, venv_dir)) print("New virtualenv created.") else: print("Virtualenv already exists.") From cdb27f431adc5420deb86c34625a2978d6e87f9a Mon Sep 17 00:00:00 2001 From: Alena Volkova Date: Thu, 28 Sep 2017 15:08:42 -0400 Subject: [PATCH 2/3] provision: Make sure the correct version of pip is installed. pip 8.0+ is required to successfully run the script (otherwise, the prefix option doesn't work). pip 9.0+ is installed because of the safety features. --- tools/provision | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/provision b/tools/provision index ef43ade0a..b6ba5bfb5 100755 --- a/tools/provision +++ b/tools/provision @@ -59,8 +59,10 @@ the Python version this command is executed with.""" # the venv's Python interpreter. `--prefix venv_dir` ensures that all modules are installed # in the right place. def install_dependencies(requirements_filename): - if subprocess.call([os.path.join(venv_dir, venv_exec_dir, 'pip'), - 'install', '--prefix', venv_dir, '-r', os.path.join(base_dir, requirements_filename)]): + pip_path = os.path.join(venv_dir, venv_exec_dir, 'pip') + subprocess.call([pip_path, 'install', 'pip>=9.0']) + if subprocess.call([pip_path, 'install', '--prefix', venv_dir, '-r', + os.path.join(base_dir, requirements_filename)]): raise OSError("The command `pip install -r {}` failed. Dependencies not installed!" .format(os.path.join(base_dir, requirements_filename))) From ec1ccd96c5a0bf9a27d096d8232fc385315b76d6 Mon Sep 17 00:00:00 2001 From: Alena Volkova Date: Thu, 28 Sep 2017 15:24:14 -0400 Subject: [PATCH 3/3] provision: Remove unnecessary imports. --- tools/provision | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/provision b/tools/provision index b6ba5bfb5..3ef3d3c38 100755 --- a/tools/provision +++ b/tools/provision @@ -3,8 +3,6 @@ import os import sys import argparse -import pip -import six import subprocess import warnings