From 532bd6eaa615c16c69446114c4e5b84311142f79 Mon Sep 17 00:00:00 2001 From: rht Date: Sat, 17 Jun 2017 15:14:59 +0200 Subject: [PATCH] Ensure virtualenv is run throughout the entire Travis dev provision. --- tools/lib/provision.py | 20 ++++---------------- tools/setup/setup_venvs.py | 29 ++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/tools/lib/provision.py b/tools/lib/provision.py index ee732e406f..e8b67baccf 100755 --- a/tools/lib/provision.py +++ b/tools/lib/provision.py @@ -244,22 +244,10 @@ def main(options): print(WARNING + "`npm install` failed; retrying..." + ENDC) setup_node_modules() - if options.is_travis: - if PY2: - MYPY_REQS_FILE = os.path.join(ZULIP_PATH, "requirements", "mypy.txt") - setup_virtualenv(PY3_VENV_PATH, MYPY_REQS_FILE, patch_activate_script=True, - virtualenv_args=['-p', 'python3']) - DEV_REQS_FILE = os.path.join(ZULIP_PATH, "requirements", "py2_dev.txt") - setup_virtualenv(PY2_VENV_PATH, DEV_REQS_FILE, patch_activate_script=True) - else: - DEV_REQS_FILE = os.path.join(ZULIP_PATH, "requirements", "py3_dev.txt") - setup_virtualenv(VENV_PATH, DEV_REQS_FILE, patch_activate_script=True, - virtualenv_args=['-p', 'python3']) - else: - # Import tools/setup_venv.py instead of running it so that we get an - # activated virtualenv for the rest of the provisioning process. - from tools.setup import setup_venvs - setup_venvs.main() + # Import tools/setup_venv.py instead of running it so that we get an + # activated virtualenv for the rest of the provisioning process. + from tools.setup import setup_venvs + setup_venvs.main(options.is_travis) # Put Python2 virtualenv activation in .bash_profile. setup_shell_profile('~/.bash_profile') diff --git a/tools/setup/setup_venvs.py b/tools/setup/setup_venvs.py index 1fa1f89413..b8828f03af 100755 --- a/tools/setup/setup_venvs.py +++ b/tools/setup/setup_venvs.py @@ -10,14 +10,29 @@ if ZULIP_PATH not in sys.path: from scripts.lib.setup_venv import setup_virtualenv -def main(): - # type: () -> None - PY2_DEV_REQS_FILE = os.path.join(ZULIP_PATH, "requirements", "py2_dev.txt") - setup_virtualenv("/srv/zulip-venv", PY2_DEV_REQS_FILE, patch_activate_script=True) +PY2_VENV_PATH = "/srv/zulip-venv" +PY3_VENV_PATH = "/srv/zulip-py3-venv" - PY3_DEV_REQS_FILE = os.path.join(ZULIP_PATH, "requirements", "py3_dev.txt") - setup_virtualenv("/srv/zulip-py3-venv", PY3_DEV_REQS_FILE, patch_activate_script=True, - virtualenv_args=['-p', 'python3']) +PY2_DEV_REQS_FILE = os.path.join(ZULIP_PATH, "requirements", "py2_dev.txt") +PY3_DEV_REQS_FILE = os.path.join(ZULIP_PATH, "requirements", "py3_dev.txt") + +PY2 = sys.version_info[0] == 2 + +def main(is_travis=False): + # type: (bool) -> None + if is_travis: + if PY2: + MYPY_REQS_FILE = os.path.join(ZULIP_PATH, "requirements", "mypy.txt") + setup_virtualenv(PY3_VENV_PATH, MYPY_REQS_FILE, patch_activate_script=True, + virtualenv_args=['-p', 'python3']) + setup_virtualenv(PY2_VENV_PATH, PY2_DEV_REQS_FILE, patch_activate_script=True) + else: + setup_virtualenv(PY3_VENV_PATH, PY3_DEV_REQS_FILE, patch_activate_script=True, + virtualenv_args=['-p', 'python3']) + else: + setup_virtualenv(PY2_VENV_PATH, PY2_DEV_REQS_FILE, patch_activate_script=True) + setup_virtualenv(PY3_VENV_PATH, PY3_DEV_REQS_FILE, patch_activate_script=True, + virtualenv_args=['-p', 'python3']) if __name__ == "__main__": main()