-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup_env.sh
53 lines (43 loc) · 1.94 KB
/
setup_env.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
#!/bin/bash
# Define the name of the virtual environment
VENV_NAME="venv_hailo_rpi5_examples"
REQUIRED_TAAPAS_VERSION="3.28.2"
# Function to check if the script is being sourced
is_sourced() {
[[ "${BASH_SOURCE[0]}" != "$0" ]]
}
# Only proceed if the script is being sourced
if is_sourced; then
echo "Setting up the environment..."
TAPPAS_VERSION=$(pkg-config --modversion hailo-tappas-core)
# Get the TAPPAS_VERSION
TAPPAS_VERSION=$(echo $TAPPAS_VERSION)
# Check if TAPPAS_VERSION is REQUIRED_TAAPAS_VERSION
if [ "$TAPPAS_VERSION" == $REQUIRED_TAAPAS_VERSION ]; then
echo "TAPPAS_VERSION is ${TAPPAS_VERSION}. Proceeding..."
else
echo "TAPPAS_VERSION is not the required version ${REQUIRED_TAPPAS_VERSION}."
fi
# Get the directory of the current script
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Check if we are in the defined virtual environment
if [[ "$VIRTUAL_ENV" == *"$VENV_NAME"* ]]; then
echo "You are in the $VENV_NAME virtual environment."
else
echo "You are not in the $VENV_NAME virtual environment."
# Check if the virtual environment exists in the same directory as the script
if [ -d "$SCRIPT_DIR/$VENV_NAME" ]; then
echo "Virtual environment exists. Activating..."
source "$SCRIPT_DIR/$VENV_NAME/bin/activate"
else
echo "Virtual environment does not exist. Creating and activating..."
python3 -m venv --system-site-packages "$SCRIPT_DIR/$VENV_NAME"
source "$SCRIPT_DIR/$VENV_NAME/bin/activate"
fi
fi
TAPPAS_POST_PROC_DIR=$(pkg-config --variable=tappas_postproc_lib_dir hailo-tappas-core)
export TAPPAS_POST_PROC_DIR
echo "TAAPAS_POST_PROC_DIR set to $TAPPAS_POST_PROC_DIR"
else
echo "This script needs to be sourced to correctly set up the environment. Please run '. $(basename "$0")' instead of executing it."
fi