forked from NodLabs/shark-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_venv.sh
executable file
·30 lines (25 loc) · 991 Bytes
/
setup_venv.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
#!/bin/bash
# Sets up a venv suitable for running samples.
# Recommend getting default 'python' to be python 3. For example on Debian:
# sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
# Or launch with python=/some/path
TD="$(cd $(dirname $0) && pwd)"
VENV_DIR="$TD/iree-samples.venv"
if [ -z "$PYTHON" ]; then
PYTHON="$(which python)"
fi
echo "Setting up venv dir: $VENV_DIR"
echo "Python: $PYTHON"
echo "Python version: $("$PYTHON" --version)"
function die() {
echo "Error executing command: $*"
exit 1
}
$PYTHON -m venv "$VENV_DIR" || die "Could not create venv."
source "$VENV_DIR/bin/activate" || die "Could not activate venv"
# Upgrade pip and install requirements. 'python' is used here in order to
# reference to the python executable from the venv.
python -m pip install --upgrade pip || die "Could not upgrade pip"
python -m pip install --upgrade -r "$TD/requirements.txt"
echo "Activate venv with:"
echo " source $VENV_DIR/bin/activate"