2016-10-11 06:30:28 +02:00
|
|
|
#!/usr/bin/env python
|
2016-06-22 21:00:50 +02:00
|
|
|
|
|
|
|
import os
|
|
|
|
import argparse
|
|
|
|
from os.path import dirname, abspath
|
|
|
|
import sys
|
|
|
|
|
|
|
|
ZULIP_PATH = dirname(dirname(dirname(abspath(__file__))))
|
|
|
|
if ZULIP_PATH not in sys.path:
|
|
|
|
sys.path.append(ZULIP_PATH)
|
|
|
|
|
2016-08-13 17:46:19 +02:00
|
|
|
from scripts.lib.zulip_tools import run
|
2016-06-22 21:00:50 +02:00
|
|
|
from scripts.lib.setup_venv import setup_virtualenv, VENV_DEPENDENCIES
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description="Create a production virtualenv with caching")
|
2016-11-20 05:45:53 +01:00
|
|
|
parser.add_argument("deploy_path")
|
2016-06-22 21:00:50 +02:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# install dependencies for setting up the virtualenv
|
|
|
|
run(["apt-get", "-y", "install"] + VENV_DEPENDENCIES)
|
|
|
|
|
2016-10-11 06:30:28 +02:00
|
|
|
python_version = sys.version_info[0]
|
|
|
|
|
2017-03-26 04:00:56 +02:00
|
|
|
# Set the current working directory to the Zulip checkout, so the api/
|
|
|
|
# relative path in requirements/common.txt works.
|
|
|
|
os.chdir(ZULIP_PATH)
|
|
|
|
|
2016-12-08 10:55:36 +01:00
|
|
|
venv_name = "zulip-venv" if sys.version_info[0] == 2 else "zulip-py3-venv"
|
2016-10-11 06:30:28 +02:00
|
|
|
cached_venv_path = setup_virtualenv(
|
2016-12-08 10:55:36 +01:00
|
|
|
os.path.join(args.deploy_path, venv_name),
|
2016-10-11 06:30:28 +02:00
|
|
|
os.path.join(ZULIP_PATH, "requirements", "py{}_prod.txt".format(python_version)),
|
|
|
|
virtualenv_args=['-p', 'python{}'.format(python_version)])
|
2016-12-08 10:55:36 +01:00
|
|
|
|
|
|
|
current_venv_path = os.path.join(args.deploy_path, 'zulip-current-venv')
|
|
|
|
run(['ln', '-s', venv_name, current_venv_path])
|
2016-06-22 21:00:50 +02:00
|
|
|
# Now the virtualenv has been activated
|