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
|
|
|
|
import sys
|
|
|
|
|
2017-09-22 08:15:01 +02:00
|
|
|
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
2016-06-22 21:00:50 +02:00
|
|
|
if ZULIP_PATH not in sys.path:
|
|
|
|
sys.path.append(ZULIP_PATH)
|
|
|
|
|
2019-01-05 01:25:33 +01:00
|
|
|
from scripts.lib.zulip_tools import overwrite_symlink, run, parse_lsb_release
|
|
|
|
from scripts.lib.setup_venv import (
|
|
|
|
setup_virtualenv, VENV_DEPENDENCIES, REDHAT_VENV_DEPENDENCIES,
|
|
|
|
FEDORA_VENV_DEPENDENCIES
|
|
|
|
)
|
2016-06-22 21:00:50 +02:00
|
|
|
|
|
|
|
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
|
2019-01-05 01:25:33 +01:00
|
|
|
distro_info = parse_lsb_release()
|
|
|
|
vendor = distro_info['DISTRIB_ID']
|
|
|
|
family = distro_info['DISTRIB_FAMILY']
|
|
|
|
if family == 'debian':
|
|
|
|
run(["apt-get", "-y", "install"] + VENV_DEPENDENCIES)
|
|
|
|
elif family == 'redhat':
|
|
|
|
if vendor in ["CentOS", "RedHat"]:
|
|
|
|
_VENV_DEPS = REDHAT_VENV_DEPENDENCIES
|
|
|
|
elif vendor == "Fedora":
|
|
|
|
_VENV_DEPS = FEDORA_VENV_DEPENDENCIES
|
|
|
|
run(["yum", "-y", "install"] + _VENV_DEPS)
|
|
|
|
else:
|
|
|
|
print("Unsupported platform: {}".format(vendor))
|
|
|
|
sys.exit(1)
|
2016-06-22 21:00:50 +02:00
|
|
|
|
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/
|
2017-11-17 02:41:06 +01:00
|
|
|
# relative path in requirements/common.in works.
|
2017-03-26 04:00:56 +02:00
|
|
|
os.chdir(ZULIP_PATH)
|
|
|
|
|
2019-01-10 01:30:44 +01:00
|
|
|
venv_name = "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-11-17 02:41:06 +01:00
|
|
|
os.path.join(ZULIP_PATH, "requirements", "prod.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')
|
2018-07-18 23:50:15 +02:00
|
|
|
overwrite_symlink(venv_name, current_venv_path)
|