summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-04-14 11:03:24 +0100
committerGitHub <noreply@github.com>2022-04-14 11:03:24 +0100
commit6b3e0ea6bdff15aa24a42f1f5938785460a323a7 (patch)
treef5dddc05792b24a753654512d6ee941b8fc3b285
parentDockerfile-workers: give the master its own log config (#12466) (diff)
downloadsynapse-6b3e0ea6bdff15aa24a42f1f5938785460a323a7.tar.xz
Use `poetry` to manage the virtualenv in debian packages (#12449)
* Use `poetry` to build venv in debian packages

Co-authored-by: Dan Callahan <danc@element.io>
Co-authored-by: Shay <hillerys@element.io>

* Changelog

* Only pull in from requirements.txt

Addresses the same problem as #12439.

* Include `test` and `all` extras

`poetry export` helpfully silently ignores an unknown extra

Haven't seen this before because it's the only place we export `all` and
`test`. I could have __sworm__ that the syntax `--extra "all test"`
worked for `poetry install`...

* Clean up requirements file on subsequence builds

* Fix shell syntax

Co-authored-by: Dan Callahan <danc@element.io>
Co-authored-by: Shay <hillerys@element.io>
-rw-r--r--changelog.d/12449.misc1
-rwxr-xr-xdebian/build_virtualenv20
-rw-r--r--debian/changelog7
-rw-r--r--debian/clean1
4 files changed, 25 insertions, 4 deletions
diff --git a/changelog.d/12449.misc b/changelog.d/12449.misc
new file mode 100644
index 0000000000..03e08aace4
--- /dev/null
+++ b/changelog.d/12449.misc
@@ -0,0 +1 @@
+Use `poetry` to manage the virtualenv in debian packages.
diff --git a/debian/build_virtualenv b/debian/build_virtualenv
index e691163619..b068792592 100755
--- a/debian/build_virtualenv
+++ b/debian/build_virtualenv
@@ -30,9 +30,19 @@ 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`.
-
+# 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
+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 --extras test -o exported_requirements.txt
+deactivate
+rm -rf "$TEMP_VENV"
+
+# Use --no-deps to only install pinned versions in exported_requirements.txt,
+# and to avoid https://github.com/pypa/pip/issues/9644
 dh_virtualenv \
     --install-suffix "matrix-synapse" \
     --builtin-venv \
@@ -41,9 +51,11 @@ dh_virtualenv \
     --preinstall="lxml" \
     --preinstall="mock" \
     --preinstall="wheel" \
+    --extra-pip-arg="--no-deps" \
     --extra-pip-arg="--no-cache-dir" \
     --extra-pip-arg="--compile" \
-    --extras="all,systemd,test"
+    --extras="all,systemd,test" \
+    --requirements="exported_requirements.txt"
 
 PACKAGE_BUILD_DIR="debian/matrix-synapse-py3"
 VIRTUALENV_DIR="${PACKAGE_BUILD_DIR}${DH_VIRTUALENV_INSTALL_ROOT}/matrix-synapse"
diff --git a/debian/changelog b/debian/changelog
index 67215aa080..fdbc92df6b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+matrix-synapse-py3 (1.58.0+nmu1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Use poetry to manage the bundled virtualenv included with this package.
+
+ -- Synapse Packaging Team <packages@matrix.org>  Wed, 30 Mar 2022 12:21:43 +0100
+
 matrix-synapse-py3 (1.57.0~rc1) stable; urgency=medium
 
   * New synapse release 1.57.0~rc1.
diff --git a/debian/clean b/debian/clean
new file mode 100644
index 0000000000..d488f298d5
--- /dev/null
+++ b/debian/clean
@@ -0,0 +1 @@
+exported_requirements.txt