-
Notifications
You must be signed in to change notification settings - Fork 2
/
update-rtd-requirements
executable file
·70 lines (59 loc) · 1.31 KB
/
update-rtd-requirements
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
set -e
prog=$(basename "$0")
srcdir=$(dirname "$0")
target="${srcdir}/requirements.readthedocs.txt"
usage() {
cat <<EOF
Usage: $0 [OPTION...]
-c, --check check if current requirements are up to date
-h, --help show this message and exit
EOF
}
ARGS=$(getopt -n "$0" -o ch -l check,help -- "$@")
eval set -- "$ARGS"
CHECK=false
while true; do
case "$1" in
-c|--check)
CHECK=true
shift
;;
-h|--help)
usage
exit 0
;;
--)
shift
break
;;
*)
echo "Unrecognized option \"$1\"" >&2
exit 1
;;
esac
done
tmpreqs=$(mktemp)
trap 'rm -f "$tmpreqs"' EXIT
(
cd "$srcdir"
cat <<EOF
#
# Don't update this directly. To update these requirements from Pipfile,
# run ./$prog from the root of the checkout.
#
EOF
# Standard package requirements so that sphinx-build can succeed.
pipenv requirements
# Dev packages required for RTD.
# https://docs.readthedocs.io/en/stable/build-default-versions.html
pipenv requirements --dev-only | grep \
-e '^sphinx\b' \
-e '^sphinx-rtd-theme\b'
) > "$tmpreqs"
if $CHECK; then
diff -u "$target" "$tmpreqs"
else
chmod 644 "$tmpreqs"
mv -f "$tmpreqs" "$target"
fi