-
Notifications
You must be signed in to change notification settings - Fork 5
/
prudentia.sh
executable file
·40 lines (33 loc) · 1.09 KB
/
prudentia.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
#!/bin/bash
#http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
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 )"
# Change cwd in Prudentia dir
cd ${DIR}
if [ -z "$( which python )" ]; then
echo "Please, install Python (>=2.6)."
exit 1
elif [ -z "$( which virtualenv )" ]; then
echo "Please, install Virtualenv."
exit 1
fi
if [ ! -d "./p-env/" ]; then
virtualenv p-env
fi
source ./p-env/bin/activate
TMP_DEPS=/tmp/prudentia_temp_deps_${RANDOM}
pip freeze -l > ${TMP_DEPS}
if ! cmp ./requirements.txt ${TMP_DEPS} > /dev/null 2>&1
then
echo "Installing Python dependencies ..."
cat ${TMP_DEPS}
pip install -r ./requirements.txt
fi
PYTHONPATH=. bin/prudentia "$@" 2>&1