From 55d6840072e4d05fb5ec6edcdae74951cc085f41 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Fri, 19 Oct 2018 11:43:37 +1300 Subject: [PATCH] Add a script to help keep requirements.txt up to date Add a script that creates a virtualenv and does the following: 1) Tests pip install -r requirements.txt 2) Runs pip freeze and diffs the output to requirements.txt (to check if any dependencies have been missed when it was last updated) 3) Runs pip list --outdated and writes the output to a file so you can see which packages might need updating (of course some may not be able to be updated easily e.g. if an API change has been made) 4) Installs safety and runs "safety check" to check if there are any known vulnerabilities Signed-off-by: Paul Eggleton --- check_requirements.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 check_requirements.sh diff --git a/check_requirements.sh b/check_requirements.sh new file mode 100644 index 0000000..faa5f0e --- /dev/null +++ b/check_requirements.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Script to be used on a regular basis to prevent requirements.txt +# from going stale +# +# Copyright (C) 2018 Intel Corporation +# +# Licensed under the MIT license, see COPYING.MIT for details + +if [ ! -f requirements.txt ] ; then + echo "No requirements.txt file, please run this in the right directory" + exit 1 +fi + +set -e + +tmpdir=`mktemp -d` +virtualenv -p python3 $tmpdir +. $tmpdir/bin/activate +pip install -r requirements.txt +newreqs="requirements.txt.updated" +echo "Creating $newreqs" +pip freeze > $newreqs +newreqsdiff="requirements.txt.diff" +echo "Creating $newreqsdiff" +diff -udN requirements.txt $newreqs > $newreqsdiff || true +outdated="outdated.txt" +echo "Creating $outdated" +pip list --outdated > $outdated +pip install pipdeptree +deptree="deptree.txt" +echo "Creating $deptree" +pipdeptree > $deptree +pip install safety +echo "Running safety check" +safety check +deactivate +rm -rf $tmpdir +