-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-wheels-macos.sh
executable file
·141 lines (116 loc) · 5.5 KB
/
build-wheels-macos.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
#!/bin/sh
set -e -x
test $# = 3 || exit 1
REPO="$1"
GIT_VERSION="$2"
SDK_VERSION="$3"
env
uname -a
sw_vers -productVersion
# this should reflect the CI image being used
PLATFORM="macosx_${SDK_VERSION}_0_`uname -m`"
ABI=cp39
PYTAG=${ABI/m/}
TAG=${PYTAG}-abi3-${PLATFORM}
PYVER=${PYTAG:2:1}.${PYTAG:3}
# setup brew dependencies
brew install pkgconf --overwrite --force
brew install --overwrite coreutils openblas swig boost python@${PYVER} tbb nlopt cminpack ceres-solver bison flex hdf5 ipopt primesieve spectra pagmo libxml2 nanoflann cuba
export PATH=/Library/Frameworks/Python.framework/Versions/${PYVER}/bin:$PATH
python${PYVER} -m pip install delocate --break-system-packages
python${PYVER} -m pip debug --verbose
SCRIPT=`greadlink -f "$0"`
SCRIPTPATH=`dirname "$SCRIPT"`
cd /tmp
git clone --depth 1 -b ${GIT_VERSION} https://github.com/${REPO}/openturns.git
cd openturns
git diff
VERSION=`cat VERSION`
#VERSION=${VERSION}.post2
#./utils/setVersionNumber.sh ${VERSION}
BREWPREFIX=`brew --prefix`
PYPREFIX=`brew --cellar python@${PYVER}`
PYLIB=`find ${PYPREFIX} -name libpython${PYVER}.dylib | grep -v config`
PYINC=`find ${PYPREFIX} -name Python.h | xargs dirname`
cmake -LAH -DCMAKE_INSTALL_PREFIX=$PWD/build/install \
-DPython_EXECUTABLE=${BREWPREFIX}/bin/python${PYVER} \
-DPython_LIBRARY=${PYLIB} \
-DPython_INCLUDE_DIR=${PYINC} \
-DFLEX_EXECUTABLE=${BREWPREFIX}/opt/flex/bin/flex \
-DBISON_EXECUTABLE=${BREWPREFIX}/opt/bison/bin/bison \
-DLIBXML2_LIBRARY=${BREWPREFIX}/opt/libxml2/lib/libxml2.dylib \
-DLIBXML2_INCLUDE_DIR=${BREWPREFIX}/opt/libxml2/include \
-DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=32 \
-DSWIG_COMPILE_FLAGS="-O1 -DPy_LIMITED_API=0x03090000 -DSWIG_HEAPTYPES" \
-DOPENTURNS_HAVE_USELOCALE=0 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${SDK_VERSION}.0 \
-B build .
cd build
make install
# 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__
# write metadata
python${PYVER} ${SCRIPTPATH}/write_distinfo.py openturns ${VERSION} ${TAG}
# create archive
zip -r openturns-${VERSION}-${TAG}.whl openturns openturns-${VERSION}.dist-info
# gather dependencies
delocate-listdeps openturns-${VERSION}-${TAG}.whl
delocate-wheel -w ${SCRIPTPATH}/wheelhouse -v openturns-${VERSION}-${TAG}.whl
delocate-listdeps --all ${SCRIPTPATH}/wheelhouse/openturns-${VERSION}-${TAG}.whl
# move conf file next to lib so it can be found using dladdr when relocated
mkdir -p openturns/.dylibs
cp -v ../../../etc/openturns/openturns.conf openturns/.dylibs
zip ${SCRIPTPATH}/wheelhouse/openturns-${VERSION}-${TAG}.whl openturns/.dylibs/openturns.conf
# test
cd /tmp
python${PYVER} -m pip install dill psutil --break-system-packages
python${PYVER} -m pip install openturns --pre --no-index -f ${SCRIPTPATH}/wheelhouse -vvv --break-system-packages
python${PYVER} -c "import openturns as ot; print(ot.__version__)"
grep -q dev <<< "${VERSION}" && exit 0
# modules
for pkgnamever in 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
curl -o utils/setVersionNumber.sh https://raw.githubusercontent.com/openturns/ottemplate/refs/heads/master/utils/setVersionNumber.sh
./utils/setVersionNumber.sh ${pkgver}
cmake -LAH -DCMAKE_INSTALL_PREFIX=$PWD/build/install \
-DCMAKE_UNITY_BUILD=ON \
-DSWIG_COMPILE_FLAGS="-O1 -DPy_LIMITED_API=0x03090000" \
-DPython_EXECUTABLE=${BREWPREFIX}/bin/python${PYVER} \
-DPython_LIBRARY=${PYLIB} \
-DPython_INCLUDE_DIR=${PYINC} \
-DOpenTURNS_DIR=/tmp/openturns/build/install/lib/cmake/openturns \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${SDK_VERSION}.0 \
-B build .
cd build
make install
ctest -E cppcheck --output-on-failure ${MAKEFLAGS}
cd install/lib/python*/site-packages/
rm -rf ${pkgname}/__pycache__
# copy libs
mkdir ${pkgname}/.dylibs
cp -v ../../lib${pkgname}.0.dylib ${pkgname}/.dylibs
install_name_tool -change @rpath/libOT.0.25.dylib @loader_path/../../openturns/.dylibs/libOT.0.25.0.dylib ${pkgname}/.dylibs/lib${pkgname}.0.dylib
install_name_tool -delete_rpath /tmp/openturns/build/install/lib ${pkgname}/.dylibs/lib${pkgname}.0.dylib
install_name_tool -delete_rpath /tmp/${pkgname}/build/install/lib ${pkgname}/.dylibs/lib${pkgname}.0.dylib
otool -l ${pkgname}/.dylibs/lib${pkgname}.0.dylib
install_name_tool -change @rpath/libOT.0.25.dylib @loader_path/../openturns/.dylibs/libOT.0.25.0.dylib ${pkgname}/_${pkgname}.so
install_name_tool -change @rpath/lib${pkgname}.0.dylib @loader_path/.dylibs/lib${pkgname}.0.dylib ${pkgname}/_${pkgname}.so
install_name_tool -delete_rpath /tmp/openturns/build/install/lib ${pkgname}/_${pkgname}.so
install_name_tool -delete_rpath /tmp/${pkgname}/build/install/lib ${pkgname}/_${pkgname}.so
otool -l ${pkgname}/_${pkgname}.so
# write metadata
python${PYVER} ${SCRIPTPATH}/write_distinfo.py ${pkgname} ${pkgver} ${TAG}
# create archive
zip -r ${SCRIPTPATH}/wheelhouse/${pkgname}-${pkgver}-${TAG}.whl ${pkgname} ${pkgname}-${pkgver}.dist-info
# test
cd /tmp
python${PYVER} -m pip install ${pkgname} --pre --no-index -f ${SCRIPTPATH}/wheelhouse -vvv --break-system-packages
python${PYVER} -c "import ${pkgname}; print(${pkgname}.__version__)"
done