11#! /usr/bin/env bash
22
3+ # Run this script inside a dockcross container to build Python wheels for ITK.
4+ #
5+ # Versions can be restricted by passing them in as arguments to the script.
6+ # For example,
7+ #
8+ # /tmp/dockcross-manylinux-x64 manylinux-build-wheels.sh cp39
9+ #
10+ # Shared library dependencies can be included wheels by mounting them to /usr/lib64 or /usr/local/lib64
11+ # before running this script.
12+ #
13+ # For example,
14+ #
15+ # DOCKER_ARGS="-v /path/to/lib.so:/usr/local/lib64/lib.so"
16+ # /tmp/dockcross-manylinux-x64 -a "$DOCKER_ARGS" manylinux-build-wheels.sh
17+ #
18+
319# -----------------------------------------------------------------------
420# These variables are set in common script:
521#
@@ -20,7 +36,8 @@ pushd /work/ITK-source > /dev/null 2>&1
2036popd > /dev/null 2>&1
2137tbb_dir=/work/oneTBB-prefix/lib64/cmake/TBB
2238# So auditwheel can find the libs
23- export LD_LIBRARY_PATH=/work/oneTBB-prefix/lib64
39+ sudo ldconfig
40+ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH} :/work/oneTBB-prefix/lib64:/usr/lib:/usr/lib64
2441
2542SINGLE_WHEEL=0
2643
@@ -149,10 +166,10 @@ for PYBIN in "${PYBINARIES[@]}"; do
149166done
150167
151168if test " ${ARCH} " == " x64" ; then
152- /opt/python/cp37-cp37m /bin/pip3 install auditwheel wheel
169+ sudo /opt/python/cp39-cp39 /bin/pip3 install auditwheel wheel
153170 # This step will fixup the wheel switching from 'linux' to 'manylinux2014' tag
154171 for whl in dist/itk_* linux_$( uname -p) .whl; do
155- /opt/python/cp37-cp37m /bin/auditwheel repair --plat manylinux2014_x86_64 ${whl} -w /work/dist/
172+ /opt/python/cp39-cp39 /bin/auditwheel repair --plat manylinux2014_x86_64 ${whl} -w /work/dist/
156173 rm ${whl}
157174 done
158175else
@@ -161,8 +178,22 @@ else
161178 rm ${whl}
162179 done
163180fi
181+ itk_core_whl=$( ls dist/itk_core* whl | head -n 1)
182+ repaired_plat1=$( echo $itk_core_whl | cut -d- -f5 | cut -d. -f1)
183+ repaired_plat2=$( echo $itk_core_whl | cut -d- -f5 | cut -d. -f2)
164184for itk_wheel in dist/itk* -linux* .whl; do
165- mv ${itk_wheel} ${itk_wheel/ linux/ manylinux2014}
185+ mkdir -p unpacked_whl packed_whl
186+ /opt/python/cp39-cp39/bin/wheel unpack -d unpacked_whl ${itk_wheel}
187+ version=$( echo ${itk_wheel} | cut -d- -f3-4)
188+ echo " Wheel-Version: 1.0" > unpacked_whl/itk-* /* .dist-info/WHEEL
189+ echo " Generator: skbuild 0.8.1" >> unpacked_whl/itk-* /* .dist-info/WHEEL
190+ echo " Root-Is-Purelib: false" >> unpacked_whl/itk-* /* .dist-info/WHEEL
191+ echo " Tag: ${version} -${repaired_plat1} " >> unpacked_whl/itk-* /* .dist-info/WHEEL
192+ echo " Tag: ${version} -${repaired_plat2} " >> unpacked_whl/itk-* /* .dist-info/WHEEL
193+ echo " " >> unpacked_whl/itk-* /* .dist-info/WHEEL
194+ /opt/python/cp39-cp39/bin/wheel pack -d packed_whl ./unpacked_whl/itk-*
195+ mv packed_whl/* .whl dist/
196+ rm -rf unpacked_whl packed_whl ${itk_wheel}
166197done
167198
168199# Install packages and test
0 commit comments