-
Notifications
You must be signed in to change notification settings - Fork 697
/
Copy pathpip_update.sh
executable file
·40 lines (31 loc) · 1.33 KB
/
pip_update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Usage: ./pip_update.sh
# Run periodically to keep Python requirements up-to-date
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
requirements_dir="${dir}/securedrop/requirements"
venv="review_env"
# This script should not be run with an active virtualenv. Calling deactivate
# does not work reliably, so instead we warn then quit.
if [[ -n $VIRTUAL_ENV ]]; then
echo "Please deactivate your virtualenv before running this script."
exit 1
fi
# Test if pip and virtualenv are available and install them if not
INSTALL='sudo apt-get install -y'
command -v pip >/dev/null 2>&1 || { eval "$INSTALL python-pip"; }
command -v virtualenv >/dev/null 2>&1 || { eval "$INSTALL python-virtualenv"; }
# Create a temporary virtualenv for the SecureDrop Python packages in our
# requirements directory
cd $requirements_dir
trap "rm -rf ${venv}" EXIT
virtualenv -p python2.7 $venv
source "${venv}/bin/activate"
pip install --upgrade pip
pip install pip-tools
# Compile new requirements (.txt) files from our top-level dependency (.in)
# files. See http://nvie.com/posts/better-package-management/
for r in "securedrop" "test"; do
# Maybe pip-tools will get its act together and standardize their cert-pinning
# syntax and this line will break. One can only hope.
pip-compile -U -o "${r}-requirements.txt" "${r}-requirements.in"
done