Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple manylinux versions #193

11 changes: 4 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ message(STATUS "SuperBuild - ITKPythonPackage_WHEEL_NAME:${ITKPythonPackage_WHEE

option(ITKPythonPackage_USE_TBB "Build and use oneTBB in the ITK python package" ON)

set(libpath "lib")
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(libpath "lib64")
endif()
if(ITK_SOURCE_DIR)
set(TBB_DIR "${ITK_SOURCE_DIR}/../oneTBB-prefix/${libpath}/cmake/TBB")
set(TBB_DIR "${ITK_SOURCE_DIR}/../oneTBB-prefix/lib/cmake/TBB")
else()
set(TBB_DIR "${CMAKE_BINARY_DIR}/../oneTBB-prefix/${libpath}/cmake/TBB")
set(TBB_DIR "${CMAKE_BINARY_DIR}/../oneTBB-prefix/lib/cmake/TBB")
endif()
set(tbb_args )
if(ITKPythonPackage_USE_TBB)
Expand Down Expand Up @@ -93,7 +89,7 @@ if(ITKPythonPackage_SUPERBUILD)

set(ITK_REPOSITORY "https://github.com/InsightSoftwareConsortium/ITK.git")

# ITK nightly-master 2022-07-04
# ITK nightly-master 2022-07-05
set(ITK_GIT_TAG "c44a7731f2")

#-----------------------------------------------------------------------------
Expand All @@ -116,6 +112,7 @@ if(ITKPythonPackage_SUPERBUILD)
-DTBB_TEST:BOOL=OFF
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/../oneTBB-prefix
-DCMAKE_INSTALL_LIBDIR:STRING=lib # Skip default initialization by GNUInstallDirs CMake module
${ep_common_cmake_cache_args}
-DCMAKE_BUILD_TYPE:STRING=Release
BUILD_BYPRODUCTS "${TBB_DIR}/TBBConfig.cmake"
Expand Down
5 changes: 4 additions & 1 deletion scripts/dockcross-manylinux-build-module-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
# scripts/dockcross-manylinux-build-module-wheels.sh cp39
#

MANYLINUX_VERSION=_2_28
IMAGE_TAG=20220705-b1eb184

# Generate dockcross scripts
docker run --rm dockcross/manylinux2014-x64:20211011-a315bdc > /tmp/dockcross-manylinux-x64
docker run --rm dockcross/manylinux${MANYLINUX_VERSION}-x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
chmod u+x /tmp/dockcross-manylinux-x64

script_dir=$(cd $(dirname $0) || exit 1; pwd)
Expand Down
5 changes: 4 additions & 1 deletion scripts/dockcross-manylinux-build-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
#
# scripts/dockcross-manylinux-build-wheels.sh cp39

MANYLINUX_VERSION=_2_28
IMAGE_TAG=20220705-b1eb184

# Generate dockcross scripts
docker run --rm dockcross/manylinux2014-x64:20211011-a315bdc > /tmp/dockcross-manylinux-x64
docker run --rm dockcross/manylinux${MANYLINUX_VERSION}-x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
chmod u+x /tmp/dockcross-manylinux-x64

script_dir=$(cd $(dirname $0) || exit 1; pwd)
Expand Down
26 changes: 12 additions & 14 deletions scripts/internal/manylinux-build-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
set -e -x

script_dir=$(cd $(dirname $0) || exit 1; pwd)
# Workaround broken FindPython3 in CMake 3.17
if test -e /usr/share/cmake-3.17/Modules/FindPython/Support.cmake; then
sudo cp ${script_dir}/Support.cmake /usr/share/cmake-3.17/Modules/FindPython/
fi

# Versions can be restricted by passing them in as arguments to the script
# For example,
Expand All @@ -28,7 +24,7 @@ else
fi

# i686 or x86_64 ?
case $(uname -p) in
case $(uname -m) in
i686)
ARCH=x86
;;
Expand All @@ -39,22 +35,22 @@ case $(uname -p) in
ARCH=aarch64
;;
*)
die "Unknown architecture $(uname -p)"
die "Unknown architecture $(uname -m)"
;;
esac

# Install prerequirements
export PATH=/work/tools/doxygen-1.8.11/bin:$PATH
case $(uname -p) in
export PATH=/work/tools/doxygen-1.8.16/bin:$PATH
case $(uname -m) in
i686)
ARCH=x86
;;
x86_64)
if ! type doxygen > /dev/null 2>&1; then
mkdir -p /work/tools
pushd /work/tools > /dev/null 2>&1
curl https://data.kitware.com/api/v1/file/5c0aa4b18d777f2179dd0a71/download -o doxygen-1.8.11.linux.bin.tar.gz
tar -xvzf doxygen-1.8.11.linux.bin.tar.gz
curl https://data.kitware.com/api/v1/file/62c4d615bddec9d0c46cb705/download -o doxygen-1.8.16.linux.bin.tar.gz
tar -xvzf doxygen-1.8.16.linux.bin.tar.gz
popd > /dev/null 2>&1
fi
;;
Expand All @@ -63,13 +59,13 @@ case $(uname -p) in
if ! type doxygen > /dev/null 2>&1; then
mkdir -p /work/tools
pushd /work/tools > /dev/null 2>&1
curl https://data.kitware.com/api/v1/file/6086e4b02fa25629b93ac66e/download -o doxygen-1.8.11.linux.aarch64.bin.tar.gz
tar -xvzf doxygen-1.8.11.linux.aarch64.bin.tar.gz
curl https://data.kitware.com/api/v1/file/62c4ed58bddec9d0c46f1388/download -o doxygen-1.8.16.linux.aarch64.bin.tar.gz
tar -xvzf doxygen-1.8.16.linux.aarch64.bin.tar.gz
popd > /dev/null 2>&1
fi
;;
*)
die "Unknown architecture $(uname -p)"
die "Unknown architecture $(uname -m)"
;;
esac
if ! type ninja > /dev/null 2>&1; then
Expand All @@ -84,4 +80,6 @@ if ! type ninja > /dev/null 2>&1; then
popd
fi

echo "Building wheels for $ARCH"
MANYLINUX_VERSION=_2_28

echo "Building wheels for $ARCH using manylinux${MANYLINUX_VERSION}"
12 changes: 6 additions & 6 deletions scripts/internal/manylinux-build-module-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ source "${script_dir}/manylinux-build-common.sh"

# Set up library paths in container so that shared libraries can be added to wheels
sudo ldconfig
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/work/oneTBB-prefix/lib64:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/work/oneTBB-prefix/lib:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64

# Compile wheels re-using standalone project and archive cache
for PYBIN in "${PYBINARIES[@]}"; do
Expand All @@ -78,8 +78,8 @@ for PYBIN in "${PYBINARIES[@]}"; do
version=$(basename $(dirname ${PYBIN}))
# Remove "m" -- not present in Python 3.8 and later
version=${version:0:9}
itk_build_dir=/work/$(basename /ITKPythonPackage/ITK-${version}*-manylinux2014_${ARCH})
ln -fs /ITKPythonPackage/ITK-${version}*-manylinux2014_${ARCH} $itk_build_dir
itk_build_dir=/work/$(basename /ITKPythonPackage/ITK-${version}*-manylinux${MANYLINUX_VERSION}_${ARCH})
ln -fs /ITKPythonPackage/ITK-${version}*-manylinux${MANYLINUX_VERSION}_${ARCH} $itk_build_dir
if [[ ! -d ${itk_build_dir} ]]; then
echo 'ITK build tree not available!' 1>&2
exit 1
Expand All @@ -95,7 +95,7 @@ for PYBIN in "${PYBINARIES[@]}"; do
-DITK_USE_SYSTEM_SWIG:BOOL=ON \
-DWRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel \
-DSWIG_EXECUTABLE:FILEPATH=${itk_build_dir}/Wrapping/Generators/SwigInterface/swig/bin/swig \
-DCMAKE_CXX_COMPILER_TARGET:STRING=$(uname -p)-linux-gnu \
-DCMAKE_CXX_COMPILER_TARGET:STRING=$(uname -m)-linux-gnu \
-DBUILD_TESTING:BOOL=OFF \
-DPython3_EXECUTABLE:FILEPATH=${Python3_EXECUTABLE} \
-DPython3_INCLUDE_DIR:PATH=${Python3_INCLUDE_DIR} \
Expand All @@ -108,7 +108,7 @@ if test "${ARCH}" == "x64"; then
# Make sure auditwheel is installed for this python exe before importing
# it in auditwheel_whitelist_monkeypatch.py
sudo ${Python3_EXECUTABLE} -m pip install auditwheel
for whl in dist/*linux_$(uname -p).whl; do
for whl in dist/*linux_$(uname -m).whl; do
# Repair wheel using monkey patch to exclude shared libraries provided in whitelist
${Python3_EXECUTABLE} "${script_dir}/auditwheel_whitelist_monkeypatch.py" \
repair ${whl} -w /work/dist/ --whitelist "${EXCLUDE_LIBS}"
Expand All @@ -117,6 +117,6 @@ if test "${ARCH}" == "x64"; then
fi
if compgen -G "dist/itk*-linux*.whl" > /dev/null; then
for itk_wheel in dist/itk*-linux*.whl; do
mv ${itk_wheel} ${itk_wheel/linux/manylinux2014}
mv ${itk_wheel} ${itk_wheel/linux/manylinux${MANYLINUX_VERSION}}
done
fi
18 changes: 9 additions & 9 deletions scripts/internal/manylinux-build-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ pushd /work/ITK-source > /dev/null 2>&1
cmake -DITKPythonPackage_BUILD_PYTHON:PATH=0 -G Ninja ../
ninja
popd > /dev/null 2>&1
tbb_dir=/work/oneTBB-prefix/lib64/cmake/TBB
tbb_dir=/work/oneTBB-prefix/lib/cmake/TBB
# So auditwheel can find the libs
sudo ldconfig
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/work/oneTBB-prefix/lib64:/usr/lib:/usr/lib64
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/work/oneTBB-prefix/lib:/usr/lib:/usr/lib64

SINGLE_WHEEL=0

Expand All @@ -56,7 +56,7 @@ for PYBIN in "${PYBINARIES[@]}"; do
build_type="Release"
compile_flags="-O3 -DNDEBUG"
source_path=/work/ITK-source/ITK
build_path=/work/ITK-$(basename $(dirname ${PYBIN}))-manylinux2014_${ARCH}
build_path=/work/ITK-$(basename $(dirname ${PYBIN}))-manylinux${MANYLINUX_VERSION}_${ARCH}
SETUP_PY_CONFIGURE="${script_dir}/../setup_py_configure.py"
SKBUILD_CMAKE_INSTALL_PREFIX=$(${Python3_EXECUTABLE} -c "from skbuild.constants import CMAKE_INSTALL_DIR; print(CMAKE_INSTALL_DIR)")

Expand All @@ -81,7 +81,7 @@ for PYBIN in "${PYBINARIES[@]}"; do
-DITK_WRAP_double:BOOL=ON \
-DITK_WRAP_complex_double:BOOL=ON \
-DITK_WRAP_IMAGE_DIMS:STRING="2;3;4" \
-DCMAKE_CXX_COMPILER_TARGET:STRING=$(uname -p)-linux-gnu \
-DCMAKE_CXX_COMPILER_TARGET:STRING=$(uname -m)-linux-gnu \
-DCMAKE_CXX_FLAGS:STRING="$compile_flags" \
-DCMAKE_C_FLAGS:STRING="$compile_flags" \
-DCMAKE_BUILD_TYPE:STRING="${build_type}" \
Expand Down Expand Up @@ -110,7 +110,7 @@ for PYBIN in "${PYBINARIES[@]}"; do
-DBUILD_TESTING:BOOL=OFF \
-DPython3_EXECUTABLE:FILEPATH=${Python3_EXECUTABLE} \
-DPython3_INCLUDE_DIR:PATH=${Python3_INCLUDE_DIR} \
-DCMAKE_CXX_COMPILER_TARGET:STRING=$(uname -p)-linux-gnu \
-DCMAKE_CXX_COMPILER_TARGET:STRING=$(uname -m)-linux-gnu \
-DCMAKE_CXX_FLAGS:STRING="$compile_flags" \
-DCMAKE_C_FLAGS:STRING="$compile_flags" \
-DCMAKE_BUILD_TYPE:STRING="${build_type}" \
Expand Down Expand Up @@ -167,13 +167,13 @@ done

if test "${ARCH}" == "x64"; then
sudo /opt/python/cp39-cp39/bin/pip3 install auditwheel wheel
# This step will fixup the wheel switching from 'linux' to 'manylinux2014' tag
for whl in dist/itk_*linux_$(uname -p).whl; do
/opt/python/cp39-cp39/bin/auditwheel repair --plat manylinux2014_x86_64 ${whl} -w /work/dist/
# This step will fixup the wheel switching from 'linux' to 'manylinux<version>' tag
for whl in dist/itk_*linux_$(uname -m).whl; do
/opt/python/cp39-cp39/bin/auditwheel repair --plat manylinux${MANYLINUX_VERSION}_x86_64 ${whl} -w /work/dist/
rm ${whl}
done
else
for whl in dist/itk_*$(uname -p).whl; do
for whl in dist/itk_*$(uname -m).whl; do
auditwheel repair ${whl} -w /work/dist/
rm ${whl}
done
Expand Down