[PATCH 1 of 3 v3] scripts: new maintainer script validate-minimum-dependency-versions

Thomas De Schampheleire patrickdepinguin at gmail.com
Sat Oct 26 20:17:03 UTC 2019


# HG changeset patch
# User Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
# Date 1572119884 -7200
#      Sat Oct 26 21:58:04 2019 +0200
# Node ID 024bd5ab79e219965015fada76a25cf19fce7195
# Parent  f00117816704857e610250e3ffca987a745a2284
scripts: new maintainer script validate-minimum-dependency-versions

Automate what we can.

This script could be added later to an encompassing script
'prepare-for-release' (which would also do other release-related steps).

diff --git a/scripts/validate-minimum-dependency-versions b/scripts/validate-minimum-dependency-versions
new file mode 100755
--- /dev/null
+++ b/scripts/validate-minimum-dependency-versions
@@ -0,0 +1,64 @@
+#!/usr/bin/env bash
+# Test that installation of all dependencies works fine if versions are set to
+# the minimum ones.
+
+set -e
+
+if [ -n "$VIRTUAL_ENV" ]; then
+    echo "This script will create its own virtualenv - please don't run it inside an existing one." >&2
+    exit 1
+fi
+
+if ! hg update --check -q .; then
+    echo "Working dir is not clean, please commit/revert changes first." >&2
+    exit 1
+fi
+
+cd "$(hg root)"
+
+venv=build/minimum-dependency-versions-venv
+log=build/minimum-dependency-versions.log
+min_requirements=build/minimum-dependency-versions-requirements.txt
+echo "virtualenv: $venv"
+echo "log: $log"
+echo "minimum requirements file: $min_requirements"
+
+# clean up previous runs
+rm -rf "$venv" "$log"
+mkdir -p "$venv"
+
+# Set minimum versions
+sed -n 's/.*"\(.*\)>=\(.*\)".*/\1==\2/p' setup.py > "$min_requirements"
+sed -n 's/>=/==/p' dev_requirements.txt >> "$min_requirements"
+
+virtualenv -p "$(command -v python2)" "$venv"
+source "$venv/bin/activate"
+pip install --upgrade pip setuptools
+# first execute basic installation
+# tee stderr to console as well as log file
+# https://stackoverflow.com/a/692407/2941347
+pip install -e . -r dev_requirements.txt python-ldap python-pam 2> >(tee "$log" >&2)
+# now fall back to minimum versions
+pip install --upgrade -r "$min_requirements"
+
+# Strip out the known Python 2.7 deprecation message.
+sed -i '/DEPRECATION: Python 2\.7 will reach the end of its life/d' "$log"
+
+# Treat any message on stderr as a problem, for the caller to interpret.
+if [ -s "$log" ]; then
+    echo
+    echo "Error: pip detected following problems:"
+    cat "$log"
+    echo
+    exit 1
+else
+    rm -f "$log"
+fi
+
+echo "Installation successful. Now running test suite..."
+
+pytest
+
+echo "Test suite successful."
+echo "You can now do additional validation using virtual env '$venv'."
+echo "When you are done, revert the changes in the repo."


More information about the kallithea-general mailing list