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-25 01:23:14 +02:00
|
|
|
from scripts.lib.zulip_tools import run, parse_os_release
|
2019-01-05 01:28:36 +01:00
|
|
|
from scripts.lib.setup_venv import (
|
|
|
|
setup_virtualenv, THUMBOR_VENV_DEPENDENCIES, YUM_THUMBOR_VENV_DEPENDENCIES
|
|
|
|
)
|
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-01-05 01:28:36 +01:00
|
|
|
family = distro_info['DISTRIB_FAMILY']
|
|
|
|
if family == 'debian':
|
|
|
|
run(["apt-get", "-y", "install"] + THUMBOR_VENV_DEPENDENCIES)
|
|
|
|
elif family == 'redhat':
|
|
|
|
run(["yum", "-y", "install"] + YUM_THUMBOR_VENV_DEPENDENCIES)
|
|
|
|
else:
|
2019-08-25 01:23:14 +02:00
|
|
|
print("Unsupported platform: {}".format(family))
|
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"),
|
2018-02-20 20:26:34 +01:00
|
|
|
virtualenv_args=['-p', 'python2.7'])
|