-
Notifications
You must be signed in to change notification settings - Fork 3
/
pipc
executable file
·41 lines (34 loc) · 1.24 KB
/
pipc
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
#!/bin/bash -ue
# Pip compiles any requirement*.in files in the current directory.
usage() {
(
echo "usage: ${0##*/} [options]"
echo "Pip compiles any requirement*.in files in the current directory."
echo
echo "options:"
(
echo " -h, --help@ show usage help"
) | column -ts@
) 1>&2
exit 1
}
if echo "$*" | grep -Eq -- '--help\b|-h\b'; then
usage
fi
# shellcheck source=../.shell_control
# shellcheck disable=SC1091
source "$HOME/.shell_control" || echo "$(tput bold)error: ~/.shell_control not installed!$(tput sgr0)" >&2
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "$REPO_ROOT"
run "pip install --upgrade pip pip-tools"
for REQ_FILE in requirements.in requirements-dev.in requirements-ci.in requirements-local.in; do
test -f "$REQ_FILE" && run "pip-compile --strip-extras '$REQ_FILE'"
done
# Workaround for a bug in pip-tools: https://github.com/jazzband/pip-tools/issues/2131
(
set +x
test -f requirements.txt && perl -pi -e "s@$REPO_ROOT/@@g" "$_"
test -f requirements-dev.txt && perl -pi -e "s@$REPO_ROOT/@@g" "$_"
test -f requirements-ci.txt && perl -pi -e "s@$REPO_ROOT/@@g" "$_"
test -f requirements-local.txt && perl -pi -e "s@$REPO_ROOT/@@g" "$_"
)