summary refs log tree commit diff
path: root/debian/build_virtualenv
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-12-20 16:48:47 +0000
committerRichard van der Hoff <richard@matrix.org>2018-12-20 16:48:47 +0000
commit0b26feb42264e742968e2a573fa1390c667f41a8 (patch)
tree2b098ed5013ce06a5bb72e540d81d9dbe71a1442 /debian/build_virtualenv
parentMerge pull request #4309 from KB1RD/KB1RD-fixes (diff)
parentClarify that py2 packages will continue to exist (diff)
downloadsynapse-0b26feb42264e742968e2a573fa1390c667f41a8.tar.xz
Merge branch 'master' into develop
Diffstat (limited to 'debian/build_virtualenv')
-rwxr-xr-xdebian/build_virtualenv48
1 files changed, 48 insertions, 0 deletions
diff --git a/debian/build_virtualenv b/debian/build_virtualenv
new file mode 100755
index 0000000000..61ffb13192
--- /dev/null
+++ b/debian/build_virtualenv
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# runs dh_virtualenv to build the virtualenv in the build directory,
+# and then runs the trial tests against the installed synapse.
+
+set -e
+
+export DH_VIRTUALENV_INSTALL_ROOT=/opt/venvs
+SNAKE=/usr/bin/python3
+
+# try to set the CFLAGS so any compiled C extensions are compiled with the most
+# generic as possible x64 instructions, so that compiling it on a new Intel chip
+# doesn't enable features not available on older ones or AMD.
+#
+# TODO: add similar things for non-amd64, or figure out a more generic way to
+# do this.
+
+case `dpkg-architecture -q DEB_HOST_ARCH` in
+    amd64)
+        export CFLAGS=-march=x86-64
+        ;;
+esac
+
+# Use --builtin-venv to use the better `venv` module from CPython 3.4+ rather
+# than the 2/3 compatible `virtualenv`.
+
+dh_virtualenv \
+    --install-suffix "matrix-synapse" \
+    --builtin-venv \
+    --setuptools \
+    --python "$SNAKE" \
+    --upgrade-pip \
+    --preinstall="lxml" \
+    --preinstall="mock" \
+    --extra-pip-arg="--no-cache-dir" \
+    --extra-pip-arg="--compile"
+
+# we copy the tests to a temporary directory so that we can put them on the
+# PYTHONPATH without putting the uninstalled synapse on the pythonpath.
+tmpdir=`mktemp -d`
+trap "rm -r $tmpdir" EXIT
+
+cp -r tests "$tmpdir"
+cd debian/matrix-synapse-py3
+
+PYTHONPATH="$tmpdir" \
+    ./opt/venvs/matrix-synapse/bin/python \
+        -B -m twisted.trial --reporter=text -j2 tests