-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathset_gray_dir.sh
52 lines (45 loc) · 1.53 KB
/
set_gray_dir.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/sh
# Get the working directoy of the script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# If the variable GRAY_PYTHON exists, remove it from PYTHONPATH.
if [ -n "${GRAY_PYTHON}" ]; then
if [ -d ${GRAY_PYTHON} ]; then
# remove the previously defined GRAY_PYTHON and it's leading ':'
PYTHONPATH=`echo $PYTHONPATH | sed -e 's#:'"${GRAY_PYTHON}"'##g'`
# remove the previously defined GRAY_PYTHON without a leading ':'
# couldn't get a \? escape on the : to work for some reason.
PYTHONPATH=`echo $PYTHONPATH | sed -e 's#'"${GRAY_PYTHON}"'##g'`
fi
fi
if [ -n "${GRAY_BIN}" ]; then
if [ -d ${GRAY_BIN} ]; then
# remove the previously defined GRAYPIPLINE_BIN and it's leading ':'
PATH=`echo $PATH | sed -e 's#:'"${GRAY_BIN}"'##g'`
# remove the previously defined GRAYPIPLINE_BIN without a leading ':'
# couldn't get a \? escape on the : to work for some reason.
PATH=`echo $PATH | sed -e 's#'"${GRAY_BIN}"'##g'`
fi
fi
# Now update those variables with the new ones, and add them to PYTHONPATH and
# PATH.
GRAY_DIR=${DIR}
GRAY_INCLUDE=${DIR}/materials
GRAY_PYTHON=$DIR/python
GRAY_BIN=$DIR/bin
# If the python path already has directories in it, append it to the back
if [ -n "$PYTHONPATH" ]; then
PYTHONPATH=$PYTHONPATH:$GRAY_PYTHON
else
PYTHONPATH=$GRAY_PYTHON
fi
if [ -n "$PATH" ]; then
PATH=$PATH:$GRAY_BIN
else
PATH=$GRAY_BIN
fi
export GRAY_DIR
export GRAY_INCLUDE
export GRAY_PYTHON
export GRAY_BIN
export PYTHONPATH
export PATH