setup_venv: Clean up VENV_DEPENDENCIES using parsed lsb_release.

This is mostly a cleanup, but it should also save 50ms in the runtime
of create-production-venv.
This commit is contained in:
Tim Abbott 2018-05-29 10:37:11 -07:00
parent 5d39a0f0fc
commit 0fabff6dda
3 changed files with 7 additions and 12 deletions

View File

@ -15,11 +15,6 @@ parser = argparse.ArgumentParser(description="Create a production virtualenv wit
parser.add_argument("deploy_path") parser.add_argument("deploy_path")
args = parser.parse_args() args = parser.parse_args()
codename = subprocess_text_output(["lsb_release", "-cs"])
if codename != "trusty":
# Workaround for the fact that trusty has a different package name here.
VENV_DEPENDENCIES.append("virtualenv")
# install dependencies for setting up the virtualenv # install dependencies for setting up the virtualenv
run(["apt-get", "-y", "install"] + VENV_DEPENDENCIES) run(["apt-get", "-y", "install"] + VENV_DEPENDENCIES)

View File

@ -1,7 +1,7 @@
import os import os
import subprocess import subprocess
from scripts.lib.zulip_tools import run, ENDC, WARNING from scripts.lib.zulip_tools import run, ENDC, WARNING, parse_lsb_release
from scripts.lib.hash_reqs import expand_reqs from scripts.lib.hash_reqs import expand_reqs
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@ -37,6 +37,12 @@ VENV_DEPENDENCIES = [
"libpq-dev", # Needed by psycopg2 "libpq-dev", # Needed by psycopg2
] ]
codename = parse_lsb_release()["DISTRIB_CODENAME"]
if codename != "trusty":
# Workaround for the fact that trusty has a different package name here.
VENV_DEPENDENCIES.append("virtualenv")
THUMBOR_VENV_DEPENDENCIES = [ THUMBOR_VENV_DEPENDENCIES = [
"libcurl4-openssl-dev", "libcurl4-openssl-dev",
"libjpeg-dev", "libjpeg-dev",

View File

@ -143,10 +143,6 @@ APT_DEPENDENCIES = {
"postgresql-9.6", "postgresql-9.6",
"postgresql-9.6-tsearch-extras", "postgresql-9.6-tsearch-extras",
"postgresql-9.6-pgroonga", "postgresql-9.6-pgroonga",
# Technically, this should be in VENV_DEPENDENCIES, but it
# doesn't exist in trusty and we don't have a conditional on
# platform there.
"virtualenv",
], ],
"trusty": UBUNTU_COMMON_APT_DEPENDENCIES + [ "trusty": UBUNTU_COMMON_APT_DEPENDENCIES + [
"postgresql-9.3", "postgresql-9.3",
@ -157,13 +153,11 @@ APT_DEPENDENCIES = {
"postgresql-9.5", "postgresql-9.5",
"postgresql-9.5-tsearch-extras", "postgresql-9.5-tsearch-extras",
"postgresql-9.5-pgroonga", "postgresql-9.5-pgroonga",
"virtualenv", # see comment on stretch
], ],
"bionic": UBUNTU_COMMON_APT_DEPENDENCIES + [ "bionic": UBUNTU_COMMON_APT_DEPENDENCIES + [
"postgresql-10", "postgresql-10",
"postgresql-10-pgroonga", "postgresql-10-pgroonga",
"postgresql-10-tsearch-extras", "postgresql-10-tsearch-extras",
"virtualenv", # see comment on stretch
], ],
} }