-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgwpysoft-init
executable file
·67 lines (55 loc) · 1.81 KB
/
gwpysoft-init
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
#!/bin/bash -e
#
# Set up a new python virtualenv for the GWpy software stack
# import library functions
here_=`cd "$( dirname $(readlink -f "${BASH_SOURCE[0]}" ) )" && pwd`
. ${here_}/gwpysoftlib.sh
# -----------------------------------------------------------------------------
# get build name and input package file
target=$1
[[ -z ${target} ]] && target=${HOME}/opt/gwpysoft
packagefile=$2
# -- install dependencies for virtualenv itself
# get python version
if [[ -z ${PYTHON_VERSION} ]]; then
PYTHON_VERSION=`python -c '
import sys;
print(".".join(map(str, sys.version_info[:2])))'`
fi
if [[ -z ${PYTHON_USER_BASE} ]]; then
PYTHON_USER_BASE=`python -c 'import site; print(site.USER_BASE)'`
fi
if [[ -z ${PYTHON_USER_SITE} ]]; then
PYTHON_USER_SITE=`python -c 'import site; print(site.USER_SITE)'`
fi
# create local directories
mkdir -p ${PYTHON_USER_SITE} 1>/dev/null
# install pip
which pip &>/dev/null || easy_install -U --prefix=${PYTHON_USER_BASE} pip
export PATH=${PATH}:${PYTHON_USER_BASE}/bin
# install virtualenv
pip install "virtualenv>=13.0" --user --quiet
echo "Virtualenv is now installed"
# -- create virtualenv
virtualenv $target --system-site-packages --clear
. $target/bin/activate
# install dependencies
if [[ -f ${packagefile} ]]; then
echo "Installing packages:"
while read package; do
# skip comments and blank lines
[[ "$package" =~ ^#.*$ ]] && continue
[[ -z "$package" ]] && continue
# install package
echo -n " $package ... "
install_package $package $target
echo "installed"
done < $packagefile
fi
echo "All packages installed"
echo "Install complete. The following packages were installed"
pip list installed --local
echo "Virtualenv is ready, you can activate the virtualenv via
. ${VIRTUAL_ENV}/bin/activate
"
deactivate