forked from andgineer/docker-amazon-dash-button-hack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
activate.sh
executable file
·48 lines (43 loc) · 1.35 KB
/
activate.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
#!/usr/bin/env bash
#
# "Set-ups or/and activates development environment"
#
VENV_FOLDER="venv"
PYTHON="python3.11"
RED='\033[1;31m'
GREEN='\033[1;32m'
CYAN='\033[1;36m'
NC='\033[0m' # No Color
if ! (return 0 2>/dev/null) ; then
# If return is used in the top-level scope of a non-sourced script,
# an error message is emitted, and the exit code is set to 1
echo
echo -e $RED"This script should be sourced like"$NC
echo " . ./activate.sh"
echo
exit 1
fi
# virtual env
if [[ ! -d ${VENV_FOLDER} ]] ; then
echo -e $CYAN"Creating virtual environment for python in ${VENV_FOLDER}"$NC
if virtualenv ${VENV_FOLDER} --python=${PYTHON}; then
echo -e $CYAN"creating VENV.."$NC
python -m venv ${VENV_FOLDER}
. ${VENV_FOLDER}/bin/activate
echo -e $CYAN"installing development dependencies.."$NC
python -m pip install --upgrade pip
python -m pip install -r requirements.dev.txt
else
echo -e $RED"Error to create virtual env. Do you have virtualenv installed?"$NC
return 1
fi
else
echo -e $CYAN"Activating virtual environment ..."$NC
. ${VENV_FOLDER}/bin/activate
fi
if type conda 2>/dev/null; then
echo -e $CYAN"deactivate conda for pure pip VENV.."$NC
conda deactivate # removing all stack if we activated conda for a number of times
conda deactivate
conda deactivate
fi