summary refs log tree commit diff
diff options
context:
space:
mode:
authorDan Callahan <danc@element.io>2022-04-06 23:58:02 +0100
committerDan Callahan <danc@element.io>2022-04-06 23:58:02 +0100
commitf0d72acebfd373b6428e8841898e90851a941192 (patch)
treeef8f9c7ff28866bac1ffb00b961cb80a40e413af
parentOnly upgrade pip in dhvirtualenv (diff)
downloadsynapse-f0d72acebfd373b6428e8841898e90851a941192.tar.xz
Install and run poetry export in dpkg-buildpackage
Signed-off-by: Dan Callahan <danc@element.io>
-rwxr-xr-xdebian/build_virtualenv20
-rw-r--r--docker/Dockerfile-dhvirtualenv10
-rw-r--r--docker/build_debian.sh3
3 files changed, 16 insertions, 17 deletions
diff --git a/debian/build_virtualenv b/debian/build_virtualenv
index b1c4e70ef4..46e1492fa6 100755
--- a/debian/build_virtualenv
+++ b/debian/build_virtualenv
@@ -30,10 +30,22 @@ case $(dpkg-architecture -q DEB_HOST_ARCH) in
         ;;
 esac
 
-# Use --builtin-venv to use the better `venv` module from CPython 3.4+ rather
-# than the 2/3 compatible `virtualenv`.
-# Use the requirements exported from poetry so that we reproduce its locked
-# environment exactly. We generate requirements.txt in build_debian.sh.
+# Manually install Poetry and export a pip-compatible `requirements.txt`
+# We need a Poetry pre-release as the export command is buggy in < 1.2
+if [ -e requirements.txt ]; then
+    # Guard against a possible future where requirements.txt lives in the repo.
+    # Otherwise, calling `poetry export` below would silently clobber it.
+    echo "requirements.txt already exists; aborting" 1>&2
+    exit 1
+fi
+TEMP_VENV="$(mktemp -d)"
+python3 -m venv "$TEMP_VENV"
+source "$TEMP_VENV/bin/activate"
+pip install -U pip
+pip install poetry==1.2.0b1
+poetry export --extras "all test" -o requirements.txt
+deactivate
+rm -rf "$TEMP_VENV"
 
 dh_virtualenv \
     --install-suffix "matrix-synapse" \
diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv
index 5e77bbb9b4..fbc1d2346f 100644
--- a/docker/Dockerfile-dhvirtualenv
+++ b/docker/Dockerfile-dhvirtualenv
@@ -85,16 +85,6 @@ RUN apt-get update -qq -o Acquire::Languages=none \
         libpq-dev \
         xmlsec1
 
-# Debian 10 (Buster)'s python3-pip package includes pip 18.1. This version was unable to
-# pull wheels. (I'd guess we need support for manylinux2010, manylinux2014 or PEP 600,
-# introduced in pip 19.0, 19.3 and 20.3 respectively.)
-# In any case, we upgrade pip rather than compile CPython extensions from source.
-RUN pip3 install -U pip
-
-# We normally use poetry 1.1.12. However we need to use a prerelease of 1.2 here,
-# which fixes a bug in poetry export that stops us from exporting for Python 3.8 builds.
-RUN pip3 install poetry==1.2.0b1
-
 COPY --from=builder /dh-virtualenv_1.2.2-1_all.deb /
 
 # install dhvirtualenv. Update the apt cache again first, in case we got a
diff --git a/docker/build_debian.sh b/docker/build_debian.sh
index 5adfbb48ca..9eae38af91 100644
--- a/docker/build_debian.sh
+++ b/docker/build_debian.sh
@@ -11,9 +11,6 @@ DIST=$(cut -d ':' -f2 <<< "${distro:?}")
 cp -aT /synapse/source /synapse/build
 cd /synapse/build
 
-# Export a requirements.txt file for the dh-virtualenv to use
-poetry export --extras "all test" -o requirements.txt
-
 # if this is a prerelease, set the Section accordingly.
 #
 # When the package is later added to the package repo, reprepro will use the