forked from unchained-capital/hermit
-
Notifications
You must be signed in to change notification settings - Fork 2
/
environment.sh
72 lines (62 loc) · 1.73 KB
/
environment.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
#
# This script sets up the local shell environment.
#
#
# Do NOT run this script (`./environment.sh` or `bash
# environment.sh`); instead source it (`source environment.sh`).
#
SCRIPT_NAME=$(basename "${0/-/}")
SOURCE_NAME=$(basename "$BASH_SOURCE")
if [ "$SCRIPT_NAME" = "$SOURCE_NAME" ]; then
echo "ERROR: Do not execute ('bash environment.sh') this script! Source it instead ('source environment.sh')"
exit 1
fi
#
# Directories
#
ROOT_DIR=$(pwd)
LIB_DIR="${ROOT_DIR}"
BIN_DIR="${ROOT_DIR}/bin"
SUBMODULES_DIR="vendor"
#
# Python virtualenv
#
VENV_NAME=".virtualenv"
VENV_DIR="${ROOT_DIR}/${VENV_NAME}"
if [ -d "$VENV_DIR" ]; then
echo "[virtualenv] Entering Python virtualenv at ${VENV_DIR}"
. "${VENV_DIR}/bin/activate"
else
echo "ERROR: Python virtualenv directory (${VENV_DIR}) does not exist. Did you run 'make' yet?"
fi
#
# PYTHONPATH
#
# We need to add this application's 'lib' dir to PYTHONPATH.
#
if [ -z $(echo "$PYTHONPATH" | grep "$LIB_DIR") ]; then
echo "[pythonpath] Adding $LIB_DIR to PYTHONPATH (${PYTHONPATH})"
export PYTHONPATH="${PYTHONPATH}:${LIB_DIR}"
else
echo "[pythonpath] $LIB_DIR already on PYTHONPATH (${PYTHONPATH})"
fi
export MYPYPATH=":$(python -m site | grep virtual | sed -e "s/^ *'//g" -e "s/',/\//g")"
#
# PATH
#
# We need to add this application's 'bin' dir to PATH.
#
if [ -z $(echo "$PATH" | grep "$BIN_DIR") ]; then
echo "[path] Adding $BIN_DIR to PATH (${PATH})"
export PATH="${PATH}:${BIN_DIR}"
else
echo "[path] $BIN_DIR already on PATH (${PATH})"
fi
#
# Submodules
#
if [ ! -e "${SUBMODULES_DIR}/pybitcointools/pybitcointools" ]; then
echo 'ERROR: No git submodules. Run `git submodule update --init`'
else
echo "[git] Submodules present"
fi