-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_requirements.sh
executable file
·36 lines (32 loc) · 1.3 KB
/
update_requirements.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
#!/bin/bash
# This follows broadly the approach from
# http://www.kennethreitz.org/essays/a-better-pip-workflow but with the
# addition of requirements_dev
# Delete and recreate a virtualenv to ensure that we don't have any extra
# packages installed in it
rm -rf .ve
virtualenv --python=python3 .ve
source .ve/bin/activate
if [[ "$1" == "--new-only" ]]; then
# If --new-only is supplied then we install the current versions of
# packages into the virtualenv, so that the only change will be any new
# packages and their dependencies.
pip install -r requirements.txt
dashupgrade=""
else
dashupgrade="--upgrade"
fi
pip install $dashupgrade -r requirements.in
pip freeze -r requirements.in > requirements.txt
# Same again for requirements_dev
if [[ "$1" == "--new-only" ]]; then
pip install -r requirements_dev.txt
fi
pip install $dashupgrade -r requirements_dev.in
cat requirements.in requirements_dev.in > requirements_combined_tmp.in
pip freeze -r requirements_combined_tmp.in > requirements_dev.txt
rm requirements_combined_tmp.in
# Put comments back on the same line (mostly for requires.io's benefit)
sed -i '$!N;s/\n#\^\^/ #/;P;D' requirements.txt requirements_dev.txt
sed -i 's/^-r.*//' requirements.txt requirements_dev.txt
sed -i 's/pkg-resources==0.0.0//' requirements.txt requirements_dev.txt