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-02 23:15:16 +02:00
|
|
|
#!/usr/bin/env python3
|
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),
|
2017-08-22 06:26:59 +02:00
|
|
|
os.path.join(ZULIP_PATH, "requirements", "prod_lock.txt"),
|
2016-10-11 06:30:28 +02:00
|
|
|
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')
|
2017-05-21 04:11:51 +02:00
|
|
|
run(['ln', '-nsf', venv_name, current_venv_path])
|
2016-06-22 21:00:50 +02:00
|
|
|
# Now the virtualenv has been activated
|