forked from datature/portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-virtualenv.sh
executable file
·52 lines (43 loc) · 1.31 KB
/
setup-virtualenv.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
#! /bin/bash
# exit when any command fails
set -e
# keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap 'echo "Exiting shell: \"${last_command}\" command failed with exit code $?."' EXIT
declare -a FILES_NEEDED=(./src/engine/run.py ./Pipfile ./Pipfile.lock)
missing_files="false"
check_if_file_exists() {
if ! test -f $1; then
missing_files="true"
echo "$1 does not exist."
fi
}
echo "Running setup bash job!"
for file in "${FILES_NEEDED[@]}"
do
check_if_file_exists $file
done
if [[ "$missing_files" == "true" ]]; then
echo "Quitting bash job due to missing files. Ensure you have the required files before continuing."
exit 0
fi
echo "Copying related engine files to portal_build..."
cp -R ./src/engine/server ./portal_build
cp ./src/engine/run.py ./portal_build
cp ./Pipfile.lock ./portal_build
cp ./Pipfile ./portal_build
cd ./portal_build
echo "Installing Python Environment in portal_build..."
echo "$OSTYPE"
if [[ "$OSTYPE" == "msys" ]]; then
python -m pip install --upgrade pip
python -m pip install pipenv
else
python3 -m pip install --upgrade pip
python3 -m pip install pipenv
fi
PIPENV_VENV_IN_PROJECT=1 PIPENV_DEFAULT_PYTHON_VERSION=3.7 pipenv sync -d
cd ..
echo "Ending setup bash job in 10 secs..."
sleep 10