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-07-21 01:56:50 +02:00
|
|
|
|
|
|
|
import os
|
|
|
|
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-07-21 01:56:50 +02:00
|
|
|
if ZULIP_PATH not in sys.path:
|
|
|
|
sys.path.append(ZULIP_PATH)
|
|
|
|
|
|
|
|
from scripts.lib.setup_venv import setup_virtualenv
|
2019-02-07 02:14:01 +01:00
|
|
|
from scripts.lib.zulip_tools import overwrite_symlink, subprocess_text_output
|
2016-07-21 01:56:50 +02:00
|
|
|
|
2017-08-09 00:38:30 +02:00
|
|
|
VENV_PATH = "/srv/zulip-py3-venv"
|
2017-06-17 15:14:59 +02:00
|
|
|
|
2017-11-17 02:41:06 +01:00
|
|
|
DEV_REQS_FILE = os.path.join(ZULIP_PATH, "requirements", "dev.txt")
|
2017-11-09 16:31:57 +01:00
|
|
|
THUMBOR_REQS_FILE = os.path.join(ZULIP_PATH, "requirements", "thumbor.txt")
|
2017-06-17 15:14:59 +02:00
|
|
|
|
2017-12-19 06:49:51 +01:00
|
|
|
def main() -> None:
|
2017-09-01 06:27:30 +02:00
|
|
|
# Get the correct Python interpreter. If we don't do this and use
|
|
|
|
# `virtualenv -p python3` to create the venv in Travis, the venv
|
|
|
|
# starts referring to the system Python interpreter.
|
|
|
|
python_interpreter = subprocess_text_output(['which', 'python3'])
|
2017-11-09 16:31:57 +01:00
|
|
|
setup_virtualenv("/srv/zulip-thumbor-venv", THUMBOR_REQS_FILE,
|
2018-01-31 11:00:16 +01:00
|
|
|
patch_activate_script=True, virtualenv_args=['-p', 'python2.7'])
|
2019-02-07 02:14:01 +01:00
|
|
|
cached_venv_path = setup_virtualenv(
|
|
|
|
VENV_PATH, DEV_REQS_FILE, patch_activate_script=True,
|
|
|
|
virtualenv_args=['-p', python_interpreter])
|
|
|
|
overwrite_symlink(cached_venv_path, os.path.join(ZULIP_PATH, "zulip-py3-venv"))
|
2016-07-21 01:56:50 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|