forked from reframe-hpc/reframe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·125 lines (105 loc) · 3.16 KB
/
bootstrap.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
#
# Copyright 2016-2024 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
# ReFrame Project Developers. See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Bootstrap script for running ReFrame from source
#
if [ -t 1 ]; then
BLUE='\033[0;34m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
fi
INFO()
{
echo -e "${BLUE}==>${NC}" ${YELLOW}$*${NC}
}
CMD()
{
echo -e "${BLUE}==>${NC}" ${YELLOW}$*${NC} && $*
}
CMD_M()
{
msg=$1
shift && echo -e "${BLUE}==> [$msg]${NC}" ${YELLOW}$*${NC} && $*
}
usage()
{
echo "Usage: $0 [-h] [+docs] [+pygelf]"
echo "Bootstrap ReFrame by pulling all its dependencies"
echo " -P EXEC Use EXEC as Python interpreter"
echo " -h Print this help message and exit"
echo " --ignore-errors Ignore installation errors"
echo " --pip-opts Pass additional options to pip."
echo " +docs Build also the documentation"
echo " +pygelf Install also the pygelf Python package"
}
while getopts "hP:-:" opt; do
case $opt in
"P") python=$OPTARG ;;
"h") usage && exit 0 ;;
"-")
case "${OPTARG}" in
"ignore-errors") ignore_errors=1 ;;
pip-opts)
PIPOPTS="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 )) ;;
pip-opts=*)
PIPOPTS=${OPTARG#*=} ;;
esac;;
"?") usage && exit 0 ;;
esac
done
if [ -z $ignore_errors ]; then
set -e
fi
shift $((OPTIND - 1))
if [ -z "$python" ]; then
python=python3
fi
while [ -n "$1" ]; do
case "$1" in
"+docs") MAKEDOCS="true" && shift ;;
"+pygelf") PYGELF="true" && shift ;;
*) usage && exit 1 ;;
esac
done
if $python -c 'import sys; sys.exit(sys.version_info[:2] >= (3, 6))'; then
echo -e "ReFrame requires Python >= 3.6 (found $($python -V 2>&1))"
exit 1
fi
venvdir=$(mktemp -d)
CMD python3 -m venv --without-pip $venvdir
CMD source $venvdir/bin/activate
_destroy_venv() {
deactivate
/bin/rm -rf $venvdir
}
trap _destroy_venv EXIT
# Create an arch-specific installation
py_pkg_prefix=external/$(uname -m)
# Install a fresh pip in the current environment
pyver=$(python3 -c 'import sys; print(".".join(str(s) for s in sys.version_info[:2]))')
if [ "$pyver" == "3.6" ]; then
get_pip="$PWD/tools/python/3.6/get-pip.py"
elif [ "$pyver" == "3.7" ]; then
get_pip="$PWD/tools/python/3.7/get-pip.py"
else
get_pip="$PWD/tools/python/get-pip.py"
fi
$python $get_pip
export PATH=$PWD/$py_pkg_prefix/usr/bin:$PATH
export PYTHONPATH=$PWD/$py_pkg_prefix:$PYTHONPATH
if [ -n "$PYGELF" ]; then
tmp_requirements=$(mktemp)
sed -e 's/^#+pygelf%//g' requirements.txt > $tmp_requirements
CMD_M +pygelf $python -m pip install --no-cache-dir -q -r $tmp_requirements --target=$py_pkg_prefix/ --upgrade $PIPOPTS && rm $tmp_requirements
else
CMD $python -m pip install --no-cache-dir -q -r requirements.txt --target=$py_pkg_prefix/ --upgrade $PIPOPTS
fi
if [ -n "$MAKEDOCS" ]; then
CMD_M +docs $python -m pip install --no-cache-dir -q -r docs/requirements.txt --target=$py_pkg_prefix/ --upgrade $PIPOPTS
make -C docs PYTHON=$python
fi