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 argparse
|
2020-06-11 00:54:34 +02:00
|
|
|
import os
|
2016-06-22 21:00:50 +02:00
|
|
|
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)
|
|
|
|
|
2020-06-11 00:54:34 +02:00
|
|
|
from scripts.lib.setup_venv import get_venv_dependencies, setup_virtualenv
|
|
|
|
from scripts.lib.zulip_tools import os_families, overwrite_symlink, parse_os_release, run
|
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-08-25 01:23:14 +02:00
|
|
|
distro_info = parse_os_release()
|
2021-02-12 08:20:45 +01:00
|
|
|
vendor = distro_info["ID"]
|
|
|
|
os_version = distro_info["VERSION_ID"]
|
2020-03-17 20:27:35 +01:00
|
|
|
VENV_DEPENDENCIES = get_venv_dependencies(vendor, os_version)
|
2019-08-30 00:14:43 +02:00
|
|
|
if "debian" in os_families():
|
2024-08-26 20:03:51 +02:00
|
|
|
run(["apt-get", "-y", "install", "--no-install-recommends", *VENV_DEPENDENCIES])
|
2019-08-30 00:14:43 +02:00
|
|
|
elif "fedora" in os_families():
|
2020-09-02 06:59:07 +02:00
|
|
|
run(["yum", "-y", "install", *VENV_DEPENDENCIES])
|
2019-01-05 01:25:33 +01:00
|
|
|
else:
|
2021-02-12 08:20:45 +01:00
|
|
|
print("Unsupported platform: {}".format(distro_info["ID"]))
|
2019-01-05 01:25:33 +01:00
|
|
|
sys.exit(1)
|
2016-06-22 21:00:50 +02:00
|
|
|
|
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(
|
2021-02-12 08:19:30 +01:00
|
|
|
os.path.join(args.deploy_path, venv_name), os.path.join(ZULIP_PATH, "requirements", "prod.txt")
|
|
|
|
)
|
2016-12-08 10:55:36 +01:00
|
|
|
|
2021-02-12 08:20:45 +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)
|