-
Notifications
You must be signed in to change notification settings - Fork 0
/
activate_venv.sh
40 lines (34 loc) · 1.24 KB
/
activate_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
31
32
33
34
35
36
37
38
39
40
#------------------------------------------------------------------------------
# Copyright (c) Pourya Shirazian
# All rights reserved.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#------------------------------------------------------------------------------
if [[ $0 == $BASH_SOURCE ]]; then
echo "This script is supposed to be sourced only"
exit 1
fi
get_current_dir() {
SOURCE="${BASH_SOURCE[0]}"
# resolve $SOURCE until the file is no longer a symlink
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
# if $SOURCE was a relative symlink, we need to resolve it relative to
# the path where the symlink file was located
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
}
get_current_dir
PYTHON3_VENV_NAME="python3-virtualenv"
# import bash functions
source ${DIR}/scripts/utils.sh
if [ -d "${DIR}/${PYTHON3_VENV_NAME}" ]; then
info "loading virtual environment under [${DIR}/${PYTHON3_VENV_NAME}]"
source ${DIR}/${PYTHON3_VENV_NAME}/bin/activate
else
error "virtual environment is missing. call bootstrap.sh first"
exit 1
fi