Files
zulip/scripts/lib/create-production-venv
Greg Price a099e698e2 py3: Switch almost all shebang lines to use python3.
This causes `upgrade-zulip-from-git`, as well as a no-option run of
`tools/build-release-tarball`, to produce a Zulip install running
Python 3, rather than Python 2.  In particular this means that the
virtualenv we create, in which all application code runs, is Python 3.

One shebang line, on `zulip-ec2-configure-interfaces`, explicitly
keeps Python 2, and at least one external ops script, `wal-e`, also
still runs on Python 2.  See discussion on the respective previous
commits that made those explicit.  There may also be some other
third-party scripts we use, outside of this source tree and running
outside our virtualenv, that still run on Python 2.
2017-08-16 17:54:43 -07:00

37 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
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)
from scripts.lib.zulip_tools import run
from scripts.lib.setup_venv import setup_virtualenv, VENV_DEPENDENCIES
parser = argparse.ArgumentParser(description="Create a production virtualenv with caching")
parser.add_argument("deploy_path")
args = parser.parse_args()
# install dependencies for setting up the virtualenv
run(["apt-get", "-y", "install"] + VENV_DEPENDENCIES)
python_version = sys.version_info[0]
# Set the current working directory to the Zulip checkout, so the api/
# relative path in requirements/common.txt works.
os.chdir(ZULIP_PATH)
venv_name = "zulip-venv" if sys.version_info[0] == 2 else "zulip-py3-venv"
cached_venv_path = setup_virtualenv(
os.path.join(args.deploy_path, venv_name),
os.path.join(ZULIP_PATH, "requirements", "py{}_prod.txt".format(python_version)),
virtualenv_args=['-p', 'python{}'.format(python_version)])
current_venv_path = os.path.join(args.deploy_path, 'zulip-current-venv')
run(['ln', '-nsf', venv_name, current_venv_path])
# Now the virtualenv has been activated