-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-python3-module.sh
214 lines (169 loc) · 6.07 KB
/
build-python3-module.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/bash
# $Id: build-nyu.sh 38 2013-06-19 19:12:11Z wangsl2001@gmail.com $
#export BUILD_WRAPPER_SCRIPT=
#export SPECIAL_RULES_FUNCTION=
#export SOURCE_CODE_LIST_WITH_INTEL_COMPILERS=
#export SOURCE_CODE_LIST_WITH_GNU_COMPILERS=
#export REGULAR_EXPRESSION_LIST_FOR_SOURCE_CODE_WITH_INTEL_COMPILERS=
#export REGULAR_EXPRESSION_LIST_FOR_SOURCE_CODE_WITH_GNU_COMPILERS=
#export INVALID_FLAGS_FOR_INTEL_COMPILERS=
#export INVALID_FLAGS_FOR_GNU_COMPILERS=
#export OPTIMIZATION_FLAGS=
#export OPTIMIZATION_FLAGS_FOR_INTEL_COMPILERS=
#export OPTIMIZATION_FLAGS_FOR_INTEL_FORTRAN_COMPILERS=
#export OPTIMIZATION_FLAGS_FOR_GNU_COMPILERS=
#export OPTIMIZATION_FLAGS_FOR_GNU_FORTRAN_COMPILERS=
#export INCLUDE_FLAGS=
#export INCLUDE_FLAGS_FOR_INTEL_COMPILERS=
#export INCLUDE_FLAGS_FOR_INTEL_FORTRAN_COMPILERS=
#export INCLUDE_FLAGS_FOR_GNU_COMPILERS=
#export INCLUDE_FLAGS_FOR_GNU_FORTRAN_COMPILERS=
#export LINK_FLAGS=
#export LINK_FLAGS_FOR_INTEL_COMPILERS="
#export LINK_FLAGS_FOR_GNU_COMPILERS="-fopenmp"
#export EXTRA_OBJECT_FILE_AND_LIBRARY_LIST=
#export STRING_MACROS=
#export FUNCTION_MACROS=
#export INTEL_MPI_BIN_PATH=
#export GNU_MPI_BIN_PATH=
#export DEFAULT_COMPILER="INTEL"
#export NO_ECHO_FLAGS=
#export REGULAR_EXPRESSIONS_FOR_NO_ECHO=
#export STRING_PREPEND_TO_ECHO=
#export DEBUG_LOG_FILE=tmp.log
#export CC=icc
#export CFLAGS=
#export LDFLAGS="-shared-intel $CFLAGS"
#export LIBS=
#export CPPFLAGS=
#export CPP="icc -E"
#export CCAS=
#export CCASFLAGS=
#export CXX=icpc
#export CXXFLAGS=
#export CXXCPP="icpc -E"
#export F77=ifort
#export FFLAGS="$CFLAGS"
#grep "module load" build-caffe.sh | grep -v "#grep" | awk '{printf "%s(\"%s\")\n", $2, $3}'
#set -e
alias die='_error_exit_ "Error in file $0 at line $LINENO\n"'
function special_rules_for_Cython()
{
export DEFAULT_COMPILER="GNU"
}
function special_rules()
{
if [ "$SPECIAL_FUNCTION" != "" ]; then
$SPECIAL_FUNCTION $*
fi
return
local arg=
for arg in $*; do
echo "$arg"
done
}
function main()
{
export LMOD_DISABLE_SAME_NAME_AUTOSWAP=yes
module use /share/apps/modulefiles
module purge
export LD_LIBRARY_PATH=
module load python3/intel/3.5.3
export MY_INTEL_PATH=/home/wang/bin/intel
local util=$MY_INTEL_PATH/util.sh
if [ -e $util ]; then
source $util
fi
export SPECIAL_RULES_FUNCTION=special_rules
if [ "$SPECIAL_RULES_FUNCTION" != "" ]; then
export BUILD_WRAPPER_SCRIPT=$(readlink -e $0)
fi
export GNU_BIN_PATH=$(dirname $(which gcc))
export INTEL_BIN_PATH=$(dirname $(which icc))
#export INTEL_MPI_BIN_PATH=$(dirname $(which mpicc))
export INVALID_FLAGS_FOR_GNU_COMPILERS="-O -O0 -O1 -O2 -O3 -g -g0 -fp-model strict -Olimit 1500 -I$INTEL_INC -I$MKL_INC"
export OPTIMIZATION_FLAGS_FOR_GNU_COMPILERS="-fPIC -fopenmp -mavx -mno-avx2"
export INVALID_FLAGS_FOR_INTEL_COMPILERS="-O -O0 -O1 -O2 -O3 -g -g0 -lm -xhost -fast -Olimit 1500"
export OPTIMIZATION_FLAGS_FOR_INTEL_COMPILERS="-fPIC -unroll -ip -axCORE-AVX2 -qopenmp -qopt-report-stdout -qopt-report-phase=openmp"
export OPTIMIZATION_FLAGS_FOR_INTEL_FORTRAN_COMPILERS="-fPIC -unroll -ip -axCORE-AVX2 -qopenmp -qopt-report-phase=openmp"
export OPTIMIZATION_FLAGS="-O3"
export CPPFLAGS=$(for inc in $(env -u INTEL_INC -u MKL_INC | grep _INC= | cut -d= -f2); do echo '-I'$inc; done | xargs)
export LDFLAGS=$(for lib in $(env | grep _LIB= | cut -d= -f2); do echo '-L'$lib; done | xargs)
prepend_to_env_variable INCLUDE_FLAGS "$CPPFLAGS"
prepend_to_env_variable LINK_FLAGS "$LDFLAGS"
prepend_to_env_variable INTEL_INCLUDE_FLAGS "-I$INTEL_INC -I$MKL_INC"
export LINK_FLAGS_FOR_INTEL_COMPILERS="-shared-intel"
export EXTRA_LINK_FLAGS="$(LD_LIBRARY_PATH_to_rpath)"
prepend_to_env_variable EXTRA_LINK_FLAGS "-L$PYTHON3_LIB -lpython3"
if [ "$DEBUG_LOG_FILE" != "" ]; then
rm -rf $DEBUG_LOG_FILE
fi
export LD_RUN_PATH=$LD_LIBRARY_PATH
local prefix=
if [ "$USER" == "wang" ]; then
#prefix=$(readlink -e ../local)
prefix=/share/apps/gensim/1.0.1/intel/python3.5
export PYTHONPATH=$prefix/lib/python3.5/site-packages:$PYTHONPATH
mkdir -p $prefix/lib/python3.5/site-packages
prefix="--prefix=$prefix"
fi
export PACKAGE_NAME=$(pwd | awk -F/ '{print $NF}' | cut -d- -f1)
echo $PACKAGE_NAME
local special_function=special_rules_for_$PACKAGE_NAME
declare -f $special_function > /dev/null 2>&1
if [[ $? == 0 ]]; then
echo "Special function: $special_function"
$special_function
export EXTRA_LINK_FLAGS="$(LD_LIBRARY_PATH_to_rpath)"
export LD_RUN_PATH=$LD_LIBRARY_PATH
export SPECIAL_FUNCTION=$special_function
fi
#export N_MAKE_THREADS=60
#export DEFAULT_COMPILER="GNU"
local args=$*
local arg=
for arg in $args; do
case $arg in
configure|conf)
echo " Run configuration ..."
export PATH=.:$MY_INTEL_PATH:$PATH
python3 setup.py build
;;
install)
echo " Run install"
export PATH=.:$MY_INTEL_PATH:$PATH
python3 setup.py install $prefix
;;
pip)
export PATH=.:$MY_INTEL_PATH:$PATH
export PYTHONUSERBASE=/home/wang/spacy-20151113/tmp
pip3 install --user --verbose --no-cache-dir spacy
exit
;;
test)
echo " Run test"
export PATH=.:$MY_INTEL_PATH:$PATH
python3 setup.py test
;;
make)
export PATH=.:$MY_INTEL_PATH:$PATH
echo " Run make"
eval "$args"
exit
;;
*)
die " Usage: $0 <argument>: configure make"
;;
esac
args=$(eval "echo $args | sed -e 's/$arg //'")
done
}
## do the main work here
## do not modify the follwoing part, we just need to modify the main function
if [ "$TO_SOURCE_BUILD_WRAPPER_SCRIPT" == "" ]; then
main "$*"
exit
else
unset -f main
fi
## do not add anything after this line