forked from gwpy/gwpysoft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgwpysoft-init
executable file
·114 lines (99 loc) · 3.35 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash -e
#
# Set up a new python virtualenv for the GWpy software stack
# get name
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_BASE} 1>/dev/null
# install pip
which pip &>/dev/null || easy_install -U --prefix=${PYTHON_USER_BASE} pip
# install virtualenv
pip install "virtualenv>=13.0" --user --quiet
echo "Virtualenv is now installed"
export PATH=${PATH}:${PYTHON_USER_BASE}/bin
# -- create virtualenv
virtualenv $target --system-site-packages --clear
. $target/bin/activate
# install dependencies
if [[ -f ${packagefile} ]]; then
while read package; do
pip install $package
done < $packagefile
fi
builddir=${TMPDIR}/gwpysoft-build
mkdir -p ${builddir} && cd ${builddir}
# install matplotlib basemap
if pip list installed --local | grep matplotlib; then
wget http://downloads.sourceforge.net/project/matplotlib/matplotlib-toolkits/basemap-1.0.7/basemap-1.0.7.tar.gz
tar -zxvf basemap-1.0.7.tar.gz
cd basemap-1.0.7
# build geos
export GEOS_DIR=${target}
cd geos-3.3.3
./configure --prefix=${GEOS_DIR} --quiet
make
make install
# install basemap
cd ../
python setup.py --quiet install
cd ../
rm -rf basemap-1.0.7
fi
# install MKL-compiled numpy/scipy
command -v icc 1>/dev/null
if [ "$?" -eq 0 ]; then
MKL_BUILD=${target}-mkl
ICC_PATH=${PROD_DIR}
# build numpy
NUMPY_VERSION=`python -c "import numpy; print(numpy.__version__)"`
wget https://github.com/numpy/numpy/archive/v${NUMPY_VERSION}.tar.gz -O numpy-${NUMPY_VERSION}.tar.gz
tar -zxvf numpy-${NUMPY_VERSION}.tar.gz
rm -f numpy-${NUMPY_VERSION}.tar.gz
cd numpy-${NUMPY_VERSION}
echo "[mkl]
library_dirs = ${ICC_PATH}/mkl/lib/intel64/
include_dirs = ${ICC_PATH}/mkl/include/
mkl_libs = mkl_rt
lapack_libs =
" > site.cfg
python setup.py config --compiler=intelem build_clib --compiler=intelem build_ext --compiler=intelem install --prefix ${MKL_BUILD}
cd -
rm -rf numpy-${NUMPY_VERSION}/
# install scipy
SCIPY_VERSION=`python -c "import scipy; print(scipy.__version__)"`
wget https://github.com/scipy/scipy/archive/v${SCIPY_VERSION}.tar.gz -O scipy-${SCIPY_VERSION}.tar.gz
tar -zxvf scipy-${SCIPY_VERSION}.tar.gz
rm -rf scipy-${SCIPY_VERSION}.tar.gz
cd scipy-${SCIPY_VERSION}
python setup.py config --compiler=intelem --fcompiler=intelem build_clib --compiler=intelem --fcompiler=intelem build_ext --compiler=intelem --fcompiler=intelem install --prefix ${MKL_BUILD}
cd -
rm -rf scipy-${SCIPY_VERSION}/
# make etc file
mkdir -p ${MKL_BUILD}/etc
MKL_ENV=${MKL_BUILD}/etc/gwpy-user-env.sh
echo '#!/usr/bin/env bash
ROOTDIR=$(readlink -f $(dirname "$BASH_SOURCE")/..)
# set PATH
PATH=${ROOTDIR}/bin:${PATH}
PYTHONPATH=${ROOTDIR}/lib64/python2.6/site-packages:${ROOTDIR}/lib/python2.6/site-packages:${PYTHONPATH}
' > ${MKL_ENV}
fi
# clean up build dir
cd
rmdir ${builddir}
deactivate