From 123c49291a03616f542e73988fc487e0dc099b71 Mon Sep 17 00:00:00 2001 From: derAnfaenger Date: Fri, 15 Sep 2017 13:24:35 +0200 Subject: [PATCH] provision: Don't fail on mypy install for Python 2. --- py3_requirements.txt | 1 + requirements.txt | 1 - tools/provision | 16 ++++++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 py3_requirements.txt diff --git a/py3_requirements.txt b/py3_requirements.txt new file mode 100644 index 0000000..2d1f719 --- /dev/null +++ b/py3_requirements.txt @@ -0,0 +1 @@ +mypy==0.521 diff --git a/requirements.txt b/requirements.txt index f102785..c036c99 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ coverage>=4.4.1 -mypy==0.521 pycodestyle==2.3.1 -e ./zulip -e ./zulip_bots diff --git a/tools/provision b/tools/provision index fca6942..e391790 100755 --- a/tools/provision +++ b/tools/provision @@ -6,6 +6,7 @@ import argparse import pip import six import subprocess +import warnings from importlib import import_module @@ -49,10 +50,17 @@ the Python version this command is executed with.""" # In order to install all required packages for the venv, `pip` needs to be executed by # the venv's Python interpreter. `--prefix venv_dir` ensures that all modules are installed # in the right place. - if subprocess.call([os.path.join(venv_dir, venv_exec_dir, 'pip'), - 'install', '--prefix', venv_dir, '-r', os.path.join(base_dir, 'requirements.txt')]): - raise OSError("The command `pip install -r {}` failed. Dependencies not installed!" - .format(os.path.join(base_dir, 'requirements.txt'))) + 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)]): + raise OSError("The command `pip install -r {}` failed. Dependencies not installed!" + .format(os.path.join(base_dir, requirements_filename))) + + install_dependencies('requirements.txt') + if sys.version_info > (3, 1): + install_dependencies('py3_requirements.txt') + else: + warnings.warn("Your Python version does not support mypy. `tools/run-mypy` will fail.") print("{green}Success!{end_format} Run\n {bold}source '{activate}'{end_format}\nto activate virtualenv.".format( green='\033[92m', bold='\033[1m', end_format='\033[0m',