From 9b6d8b70f86c82b54a206078eade943ce4ee41a6 Mon Sep 17 00:00:00 2001 From: Sean Quah Date: Wed, 23 Mar 2022 17:37:27 +0000 Subject: [PATCH] Use poetry to installed locked dependencies when `poetry.lock` exists Signed-off-by: Sean Quah --- scripts/synapse_sytest.sh | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/scripts/synapse_sytest.sh b/scripts/synapse_sytest.sh index f15528f39..e73f4b3d3 100755 --- a/scripts/synapse_sytest.sh +++ b/scripts/synapse_sytest.sh @@ -135,11 +135,33 @@ if [ -n "$OFFLINE" ]; then # pip will want to install any requirements for the build system # (https://github.com/pypa/pip/issues/5402), so we have to provide a # directory of pre-downloaded build requirements. + echo "Installing Synapse using pip in offline mode..." /venv/bin/pip install --no-index --find-links /pypi-offline-cache /synapse else - # We've already created the virtualenv, but lets double check we have all - # deps. - /venv/bin/pip install -q --upgrade --no-cache-dir /synapse[redis] + if [ -f "/synapse/poetry.lock" ]; then + # Install Synapse and dependencies using poetry, respecting the lockfile. + # The virtual env will already be populated with dependencies from the + # Docker build. + echo "Installing Synapse using poetry..." + if [ -d /synapse/.venv ]; then + # There was a virtual env in the source directory for some reason. + # We want to use our own, so remove it. + rm -rf /synapse/.venv + fi + ln -s -T /venv /synapse/.venv # reuse the existing virtual env + pushd /synapse + poetry install --extras redis + popd + else + # Install Synapse and dependencies using pip. As of pip 20.1, this will + # try to build Synapse in-tree, which means writing changes to the source + # directory. + # The virtual env will already be populated with dependencies from the + # Docker build. + echo "Installing Synapse using pip..." + /venv/bin/pip install -q --upgrade --no-cache-dir /synapse[redis] + fi + /venv/bin/pip install -q --upgrade --no-cache-dir \ lxml psycopg2 coverage codecov tap.py coverage_enable_subprocess