Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·97 lines (81 loc) · 2.16 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·97 lines (81 loc) · 2.16 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
set -euo pipefail
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
VENV="$ROOT/.venv"
PYTHON=python3
TESTGRES_DIR="${PGLAB_TESTGRES_DIR:-}"
INSTALL_SYSTEM_DEPS=1
usage() {
cat <<USAGE
Usage: ./setup.sh [options]
Options:
--skip-system-deps do not install OS packages
--python PATH Python executable (default: python3)
--venv PATH venv directory (default: ./.venv)
--testgres-dir PATH install Testgres editable from this checkout
-h, --help show this help
Until the target-execution-context API is available in a released Testgres,
use --testgres-dir with a compatible checkout.
USAGE
}
while [[ $# -gt 0 ]]; do
case "$1" in
--skip-system-deps)
INSTALL_SYSTEM_DEPS=0
shift
;;
--python)
PYTHON="$2"
shift 2
;;
--venv)
VENV="$2"
shift 2
;;
--testgres-dir)
TESTGRES_DIR="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1" >&2
usage >&2
exit 2
;;
esac
done
if [[ $INSTALL_SYSTEM_DEPS -eq 1 ]]; then
"$ROOT/scripts/install-system-deps.sh"
fi
command -v "$PYTHON" >/dev/null 2>&1 || {
echo "Python executable not found: $PYTHON" >&2
exit 1
}
if [[ ! -x "$VENV/bin/python" ]]; then
"$PYTHON" -m venv "$VENV"
fi
"$VENV/bin/python" -m pip install --upgrade pip setuptools wheel
if [[ -n "$TESTGRES_DIR" ]]; then
TESTGRES_DIR=$(cd -- "$TESTGRES_DIR" && pwd)
echo "==> Installing Testgres from $TESTGRES_DIR"
"$VENV/bin/python" -m pip install -e "$TESTGRES_DIR"
fi
"$VENV/bin/python" -m pip install -e "$ROOT[test]"
"$VENV/bin/python" -m pip check
"$VENV/bin/python" "$ROOT/tools/verify_install.py"
cat <<DONE
Setup complete.
Virtual environment:
$VENV
For integration tests:
export PG_BIN=/path/to/postgres/bin
export PGLAB_OS_USER=postgres
export PGLAB_DB_USER=postgres
export PGLAB_TEST_ROOT=/var/tmp
./scripts/doctor.sh
./scripts/run-smoke.sh
./scripts/run-tests.sh
DONE