-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-wheels-linux.sh
executable file
·114 lines (90 loc) · 3.84 KB
/
build-wheels-linux.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
#!/bin/sh
set -e -x
test $# = 2 || exit 1
REPO="$1"
GIT_VERSION="$2"
ABI=cp39
PLATFORM=manylinux2014_x86_64
PYTAG=${ABI/m/}
TAG=${PYTAG}-abi3-${PLATFORM}
SCRIPT=`readlink -f "$0"`
SCRIPTPATH=`dirname "$SCRIPT"`
export PATH=/opt/python/${PYTAG}-${ABI}/bin/:$PATH
cd /tmp
git clone --depth 1 -b ${GIT_VERSION} https://github.com/${REPO}/openturns.git
cd openturns
VERSION=`cat VERSION`
#mv openturns-${VERSION} openturns-${VERSION}.post2
#VERSION=${VERSION}.post2
#./utils/setVersionNumber.sh ${VERSION}
cmake -DCMAKE_INSTALL_PREFIX=$PWD/build/install \
-DPython_EXECUTABLE=/opt/python/${PYTAG}-${ABI}/bin/python \
-DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=32 \
-DSWIG_COMPILE_FLAGS="-O1 -DPy_LIMITED_API=0x03090000 -DSWIG_HEAPTYPES" \
-B build .
cd build
make install
OLD_LIBOT=`basename install/lib64/libOT.so.0.*`
# run a few tests
ctest -R "Ipopt|Bonmin|Dlib_std|NLopt|Study|SymbolicFunction|SquareMatrix|CMinpack|Ceres|Sample_csv|Pagmo|Cuba|KDTree" -E cppcheck --output-on-failure ${MAKEFLAGS}
cd install/lib*/python*/site-packages/
rm -rf openturns/__pycache__
# move conf file next to lib so it can be found using dladdr when relocated
mkdir -p openturns.libs
cp -v ../../../etc/openturns/openturns.conf openturns.libs
# write metadata
python ${SCRIPTPATH}/write_distinfo.py openturns ${VERSION} ${TAG}
# create archive
zip -r openturns-${VERSION}-${TAG}.whl openturns openturns.libs openturns-${VERSION}.dist-info
auditwheel show openturns-${VERSION}-${TAG}.whl
auditwheel repair openturns-${VERSION}-${TAG}.whl -w /io/wheelhouse/
# test
cd /tmp
pip install dill psutil
pip install openturns --pre --no-index -f /io/wheelhouse
python -c "import openturns as ot; print(ot.__version__)"
grep -q dev <<< "${VERSION}" && exit 0
# lookup new OT lib name
unzip /io/wheelhouse/openturns-${VERSION}-${TAG}.manylinux_2_17_x86_64.whl
readelf -d openturns.libs/libOT-*.so*
NEW_LIBOT=`basename openturns.libs/libOT-*.so*`
cd -
# modules
for pkgnamever in otfftw-0.16 otmixmod-0.18 otmorris-0.17 otrobopt-0.15 otsvm-0.15
do
pkgname=`echo ${pkgnamever} | cut -d "-" -f1`
pkgver=`echo ${pkgnamever} | cut -d "-" -f2`
cd /tmp
git clone --depth 1 -b v${pkgver} https://github.com/openturns/${pkgname}.git && cd ${pkgname}
pkgver=${pkgver}.post1
./utils/setVersionNumber.sh ${pkgver}
cmake -DCMAKE_INSTALL_PREFIX=$PWD/build/install -DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_UNITY_BUILD=ON \
-DSWIG_COMPILE_FLAGS="-O1 -DPy_LIMITED_API=0x03090000" \
-DPython_EXECUTABLE=/opt/python/${PYTAG}-${ABI}/bin/python \
-DOpenTURNS_DIR=/tmp/openturns/build/install/lib64/cmake/openturns \
-B build .
cd build
make install
ctest -E cppcheck --output-on-failure ${MAKEFLAGS}
cd install/lib*/python*/site-packages/
rm -rf ${pkgname}/__pycache__
# write metadata
python ${SCRIPTPATH}/write_distinfo.py ${pkgname} ${pkgver} ${TAG}
# copy libs
mkdir ${pkgname}.libs
cp -v ../../lib${pkgname}.so.0 ${pkgname}.libs
if test "${pkgname}" = "otfftw"; then cp -v /usr/local/lib/libfftw3.so.3 otfftw.libs; fi
if test "${pkgname}" = "otmixmod"; then cp -v /usr/local/lib*/libmixmod.so.* otmixmod.libs; fi
# relink
patchelf --remove-rpath ${pkgname}.libs/lib${pkgname}.so.0 ${pkgname}/_${pkgname}.so
patchelf --force-rpath --set-rpath "\$ORIGIN/../${pkgname}.libs:\$ORIGIN/../openturns.libs" ${pkgname}.libs/lib${pkgname}.so.0 ${pkgname}/_${pkgname}.so
patchelf --print-rpath ${pkgname}.libs/lib${pkgname}.so.0 ${pkgname}/_${pkgname}.so
patchelf --replace-needed ${OLD_LIBOT} ${NEW_LIBOT} ${pkgname}.libs/lib${pkgname}.so.0 ${pkgname}/_${pkgname}.so
# create archive
zip -r /io/wheelhouse/${pkgname}-${pkgver}-${TAG}.whl ${pkgname} ${pkgname}.libs ${pkgname}-${pkgver}.dist-info
# test
cd /tmp
pip install ${pkgname} --pre --no-index -f /io/wheelhouse
python -c "import ${pkgname}; print(${pkgname}.__version__)"
done