-
Notifications
You must be signed in to change notification settings - Fork 77
/
demisto-sdk-development.sh
executable file
·83 lines (69 loc) · 2.54 KB
/
demisto-sdk-development.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
#!/bin/zsh
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
VIRTUALENV_NAME="demisto-sdk-dev"
# Get current working dir
SDK_WORKDIR=`pwd`
# Arguments handling
if [[ $1 == "-h" ]]; then
printf "This script creates environment for developing demisto-sdk, The following steps are done:
1. Installing virtualenv-wrapper.
2. Create virtualenv \"${VIRTUALENV_NAME}\".
3. Installing in virtualenv demisto-sdk as editable version.
Notes:
1. This script requires python3 installed.
2. For more information please see the Contribution guide.
\n"
exit 0
fi
# Validate mandatoy executables for execution
executables_exists=0
for executable in pyenv python3 git
do
if ! command -v $executable &> /dev/null
then
printf "${RED}$executable isn't installed, Please install $executable before using this script!${NC}\n"
executables_exists=1
fi
done
if [[ executables_exists -eq 1 ]]; then
exit 1
fi
# Validate Pyenv configure correctly
if [[ "*/.pyenv/*" = $(which python3) ]]; then
printf "${RED}Python3 executable source isn't managed by pyenv, Please verify global var PATH configuration${NC}\n"
exit 1
fi
# Install pyenv-vritualenvwrapper
printf "Installing pyenv-vritualenvwrapper\n"
rm -rf $(pyenv root)/plugins/pyenv-virtualenvwrapper
command git clone https://github.com/pyenv/pyenv-virtualenvwrapper.git $(pyenv root)/plugins/pyenv-virtualenvwrapper
if [ $? -eq 0 ]; then
printf "pyenv-virtualenvwrapper installed ${GREEN}successfully${NC}\n"
else
printf "${RED}pyenv-virtualenvwrapper can't installed using brew$\nAdditional error details:\n${output}${NC}"
exit 1
fi
# Init PATH variables
if [[ $SHELL == *"bin/zsh"* ]]; then
source ~/.zshrc
elif [[ $SHELL == *"bin/bash"* ]]; then
source ~/.bash_profile
else
printf "${RED}Currnltly only bash/zsh is supported as base shell.\n${output}${NC}"
printf "${RED}Run 'export SHELL=/bin/zsh' or 'export SHELL=/bin/bash' and rerun the script.\n${output}${NC}"
exit 1
fi
# Initializing pyenv-vritualenvwrapper
printf "Initiallizing pyenv-vritualenvwrapper\n"
pyenv virtualenvwrapper
echo pyenv virtualenvwrapper >> ~/.zshrc
echo pyenv virtualenvwrapper >> ~/.bash_profile
# Creating development enviorment
rmvirtualenv ${VIRTUALENV_NAME}
mkvirtualenv ${VIRTUALENV_NAME}
pip3 install -e ${SDK_WORKDIR}
# Summary log
printf "\n\nDemisto-sdk virtual env setup finished succefully:\n 1. Restart your terminal.\n 2. In order to activate enviorment ${GREEN}workon ${VIRTUALENV_NAME}${NC}\n 3. Inorder to deactivate enviorment ${RED}deactivate${NC}\n"
exit 0