2017-10-29 00:36:05 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import os
|
|
|
|
import argparse
|
|
|
|
import sys
|
|
|
|
|
|
|
|
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
if ZULIP_PATH not in sys.path:
|
|
|
|
sys.path.append(ZULIP_PATH)
|
|
|
|
|
2019-08-30 00:14:43 +02:00
|
|
|
from scripts.lib.zulip_tools import os_families, run, parse_os_release
|
2019-01-05 01:28:36 +01:00
|
|
|
from scripts.lib.setup_venv import (
|
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
|
|
|
setup_virtualenv, THUMBOR_VENV_DEPENDENCIES, YUM_THUMBOR_VENV_DEPENDENCIES,
|
2019-01-05 01:28:36 +01:00
|
|
|
)
|
2017-10-29 00:36:05 +02:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description="Create a thumbor virtualenv with caching")
|
|
|
|
parser.add_argument("deploy_path")
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# install dependencies for setting up the virtualenv
|
2019-08-25 01:23:14 +02:00
|
|
|
distro_info = parse_os_release()
|
2019-08-30 00:14:43 +02:00
|
|
|
if "debian" in os_families():
|
2019-01-05 01:28:36 +01:00
|
|
|
run(["apt-get", "-y", "install"] + THUMBOR_VENV_DEPENDENCIES)
|
2019-08-30 00:14:43 +02:00
|
|
|
elif "fedora" in os_families():
|
2019-01-05 01:28:36 +01:00
|
|
|
run(["yum", "-y", "install"] + YUM_THUMBOR_VENV_DEPENDENCIES)
|
|
|
|
else:
|
2019-08-30 00:14:43 +02:00
|
|
|
print("Unsupported platform: {}".format(distro_info['ID']))
|
2019-01-05 01:28:36 +01:00
|
|
|
sys.exit(1)
|
2017-10-29 00:36:05 +02:00
|
|
|
|
|
|
|
venv_name = "zulip-thumbor-venv"
|
|
|
|
cached_venv_path = setup_virtualenv(
|
|
|
|
os.path.join(args.deploy_path, venv_name),
|
2017-11-17 02:41:06 +01:00
|
|
|
os.path.join(ZULIP_PATH, "requirements", "thumbor.txt"),
|
2020-02-05 06:54:43 +01:00
|
|
|
python2=True)
|