diff --git a/tools/provision b/tools/provision index e3917906f..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 @@ -24,10 +22,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.") @@ -51,8 +57,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)))