2828# See https://github.com/dockcross/dockcross for available versions and tags.
2929# For instance, `export MANYLINUX_VERSION=2014`
3030#
31+ # `TARGET_ARCH`: Target architecture for which wheels should be built.
32+ # For instance, `export MANYLINUX_VERSION=aarch64`
33+ #
3134# `IMAGE_TAG`: Specialized manylinux image tag to use for building.
32- # For instance, `export IMAGE_TAG=20221205-459c9f0`
35+ # For instance, `export IMAGE_TAG=20221205-459c9f0`.
36+ # Tagged images are available at:
37+ # - https://github.com/dockcross/dockcross (x64 architecture)
38+ # - https://quay.io/organization/pypa (ARM architecture)
3339#
3440# `ITK_MODULE_PREQ`: Prerequisite ITK modules that must be built before the requested module.
3541# See notes in `dockcross-manylinux-build-module-deps.sh`.
3642#
3743# `ITK_MODULE_NO_CLEANUP`: Option to skip cleanup steps.
3844#
45+ # - `NO_SUDO`: Disable the use of superuser permissions for running docker.
46+ #
3947# #######################################################################
4048
4149# Handle case where the script directory is not the working directory
4250script_dir=$( cd $( dirname $0 ) || exit 1; pwd)
4351source " ${script_dir} /dockcross-manylinux-set-vars.sh"
4452
45- echo " ITK_MODULE_PREQ ${ITK_MODULE_PREQ} "
4653if [[ -n ${ITK_MODULE_PREQ} ]]; then
54+ echo " Building module dependencies ${ITK_MODULE_PREQ} "
4755 source " ${script_dir} /dockcross-manylinux-build-module-deps.sh"
4856fi
4957
50- # Generate dockcross scripts
51- docker run --rm dockcross/manylinux${MANYLINUX_VERSION} -x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
52- chmod u+x /tmp/dockcross-manylinux-x64
53-
58+ # Set up paths and variables for build
5459mkdir -p $( pwd) /tools
5560chmod 777 $( pwd) /tools
56- # Build wheels
5761mkdir -p dist
5862DOCKER_ARGS=" -v $( pwd) /dist:/work/dist/ -v ${script_dir} /..:/ITKPythonPackage -v $( pwd) /tools:/tools"
5963DOCKER_ARGS+=" -e MANYLINUX_VERSION"
@@ -64,9 +68,28 @@ if [[ -n ${LD_LIBRARY_PATH} ]]; then
6468 done
6569fi
6670
67- /tmp/dockcross-manylinux-x64 \
68- -a " $DOCKER_ARGS " \
69- " /ITKPythonPackage/scripts/internal/manylinux-build-module-wheels.sh" " $@ "
71+ if [[ " ${TARGET_ARCH} " = " aarch64" ]]; then
72+ echo " Install aarch64 architecture emulation tools to perform build for ARM platform"
73+
74+ if [[ ! ${NO_SUDO} ]]; then
75+ docker_prefix=" sudo"
76+ fi
77+
78+ ${docker_prefix} docker run --privileged --rm tonistiigi/binfmt --install all
79+
80+ # Build wheels
81+ DOCKER_ARGS+=" -v $( pwd) :/work/ --rm"
82+ ${docker_prefix} docker run $DOCKER_ARGS ${CONTAINER_SOURCE} " /ITKPythonPackage/scripts/internal/manylinux-aarch64-build-module-wheels.sh" " $@ "
83+ else
84+ # Generate dockcross scripts
85+ docker run --rm ${CONTAINER_SOURCE} > /tmp/dockcross-manylinux-x64
86+ chmod u+x /tmp/dockcross-manylinux-x64
87+
88+ # Build wheels
89+ /tmp/dockcross-manylinux-x64 \
90+ -a " $DOCKER_ARGS " \
91+ " /ITKPythonPackage/scripts/internal/manylinux-build-module-wheels.sh" " $@ "
92+ fi
7093
7194if [[ -z ${ITK_MODULE_NO_CLEANUP} ]]; then
7295 source " ${script_dir} /dockcross-manylinux-cleanup.sh"
0 commit comments