-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathbuild_all_spack.sh
executable file
·144 lines (132 loc) · 4.16 KB
/
build_all_spack.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
set -e
# choose local directory where packages will be installed
if [ -z "$TESTRELDIR" ]; then
export INSTDIR=`pwd`/install
else
export INSTDIR="$TESTRELDIR"
fi
cmake_option="RelWithDebInfo"
pyInstallStyle="develop"
psana_setup_args=""
force_clean=0
no_daq=1
no_ana=0
no_shmem=0
build_ext_list=""
while getopts "c:p:s:b:fdam" opt; do
case $opt in
c) cmake_option="$OPTARG"
;;
d) no_daq=1
;;
a) no_ana=1
;;
m) no_shmem=1
;;
p) pyInstallStyle="$OPTARG"
;;
s) psana_setup_args="$OPTARG"
;;
b) build_ext_list="$OPTARG"
;;
f) force_clean=1 # Force clean is required building between rhel6&7
;;
\?) echo "Invalid option -$OPTARG" >&2
exit 1
;;
esac
done
pyver=$(python -c "import sys; print(str(sys.version_info.major)+'.'+str(sys.version_info.minor))")
echo Pyver ${pyver}
echo "CMAKE_BUILD_TYPE:" $cmake_option
echo "Python install option:" $pyInstallStyle
echo "build_ext_list:" $build_ext_list
export BUILD_LIST=$build_ext_list
if [[ $force_clean == 1 ]]; then
echo "force_clean"
if [ -d "$INSTDIR" ]; then
rm -rf "$INSTDIR"
fi
if [ -d xtcdata/build ]; then
rm -rf xtcdata/build
fi
if [ -d psdaq/build ]; then
rm -rf psdaq/build
fi
if [ -d psalg/build ]; then
rm -rf psalg/build
fi
fi
function cmake_build() {
cd $1
shift
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$INSTDIR -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH -DCMAKE_BUILD_TYPE=$cmake_option $@ ..
make -j 4 install
cd ../..
}
# "python setup.py develop" seems to not create this for you
# (although "install" does)
mkdir -p $INSTDIR/lib/python$pyver/site-packages/
if [[ $pyInstallStyle == "develop" ]]; then
pipOptions="--editable"
else
pipOptions=""
fi
cmake_build xtcdata
if [[ $no_shmem == 0 ]]; then
cmake_build psalg
else
cmake_build psalg -DBUILD_SHMEM=OFF
fi
cd psalg
python -m pip install --no-deps --prefix=$INSTDIR $pipOptions .
cd ..
if [ $no_daq == 0 ]; then
# to build psdaq with setuptools
cmake_build psdaq
cd psdaq
# force build of the extensions. do this because in some cases
# setup.py is unable to detect if an external header file changed
# (e.g. in xtcdata). but in many cases it is fine without "-f" - cpo
if [ $pyInstallStyle == "develop" ]; then
python setup.py build_ext -f --inplace
fi
pip install --no-deps --prefix=$INSTDIR $pipOptions .
cd ..
fi
if [[ $no_ana == 0 ]]; then
# to build psana with setuptools
cd psana
# force build of the extensions. do this because in some cases
# setup.py is unable to detect if an external header file changed
# (e.g. in xtcdata). but in many cases it is fine without "-f" - cpo
if [[ $pyInstallStyle == "develop" ]]; then
python setup.py build_ext -f --inplace
fi
python -m pip install --no-deps --prefix=$INSTDIR $pipOptions .
fi
# The removal of site.py in setup 49.0.0 breaks "develop" installations
# which are outside the normal system directories: /usr, /usr/local,
# $HOME/.local. etc. See: https://github.com/pypa/setuptools/issues/2295
# The suggested fix, in the bug report, is the following: "I recommend
# that the project use pip install --prefix or possibly pip install
# --target to install packages and supply a sitecustomize.py to ensure
# that directory ends up as a site dir and gets .pth processing. That
# approach should be future-proof (at least against the sunset of
# easy_install). All python setup.py commands in the code above have
# been replaced with pip commands. The following code implements the
# sitecustomize.py file. Pip bilds the python modules in a sandbox,
# so it requires all the code for the module to be in the same
# folder. The C++ code for the modules built in psana was therefore
# moved from psalg to psana.
if [[ $pyInstallStyle == "develop" ]]; then
if [ ! -f $INSTDIR/lib/python$pyver/site-packages/site.py ] && \
[ ! -f $INSTDIR/lib/python$pyver/site-packages/sitecustomize.py ]; then
cat << EOF > $INSTDIR/lib/python$pyver/site-packages/sitecustomize.py
import site
site.addsitedir('$INSTDIR/lib/python$pyver/site-packages')
EOF
fi
fi