Skip to content

Commit

Permalink
ENH: Expose MANYLINUX_VERSION and IMAGE_TAG for Linux builds
Browse files Browse the repository at this point in the history
Replaces `TARBALL_SPECIALIZATION` parameter with distinct
`MANYLINUX_VERSION` and `IMAGE_TAG` parameters to be set by the user
prior to build. The resulting script fetches the correct dockcross image
for building specialized wheels and artifacts.

Resolves an issue where `manylinux2014` wheels were attempted to build
on `-manylinux_2_28` images.
  • Loading branch information
tbirdso committed Nov 30, 2022
1 parent a00ac4c commit 583e7a6
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 11 deletions.
15 changes: 13 additions & 2 deletions scripts/dockcross-manylinux-build-module-wheels.sh
Expand Up @@ -16,9 +16,19 @@
# export LD_LIBRARY_PATH="/path/to/OpenCL.so:/path/to/OpenCL.so.1.2"
# scripts/dockcross-manylinux-build-module-wheels.sh cp39
#
# A specialized manylinux image and tag can be used by exporting
# MANYLINUX_VERSION and IMAGE_TAG before running this script.
# See https://github.com/dockcross/dockcross for available versions and tags.
#
# For example,
#
# export MANYLINUX_VERSION=2014
# export IMAGE_TAG=20221108-102ebcc
# scripts/dockcross-manylinux-build-module-wheels.sh cp39
#

MANYLINUX_VERSION=_2_28
IMAGE_TAG=20221128-2024e4b
MANYLINUX_VERSION=${MANYLINUX_VERSION:=_2_28}
IMAGE_TAG=${IMAGE_TAG:=20221128-2024e4b}

# Generate dockcross scripts
docker run --rm dockcross/manylinux${MANYLINUX_VERSION}-x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
Expand All @@ -31,6 +41,7 @@ chmod 777 $(pwd)/tools
# Build wheels
mkdir -p dist
DOCKER_ARGS="-v $(pwd)/dist:/work/dist/ -v $script_dir/..:/ITKPythonPackage -v $(pwd)/tools:/tools"
DOCKER_ARGS+=" -e MANYLINUX_VERSION"
# Mount any shared libraries
if [[ -n ${LD_LIBRARY_PATH} ]]; then
for libpath in ${LD_LIBRARY_PATH//:/ }; do
Expand Down
16 changes: 14 additions & 2 deletions scripts/dockcross-manylinux-build-wheels.sh
Expand Up @@ -6,9 +6,20 @@
# For example,
#
# scripts/dockcross-manylinux-build-wheels.sh cp39
#
# A specialized manylinux image and tag can be used by exporting to
# MANYLINUX_VERSION and IMAGE_TAG before running this script.
# See https://github.com/dockcross/dockcross for available versions and tags.
#
# For example,
#
# export MANYLINUX_VERSION=2014
# export IMAGE_TAG=20221108-102ebcc
# scripts/dockcross-manylinux-build-module-wheels.sh cp39
#

MANYLINUX_VERSION=_2_28
IMAGE_TAG=20221128-2024e4b
MANYLINUX_VERSION=${MANYLINUX_VERSION:=_2_28}
IMAGE_TAG=${IMAGE_TAG:=20221128-2024e4b}

# Generate dockcross scripts
docker run --rm dockcross/manylinux${MANYLINUX_VERSION}-x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
Expand All @@ -20,6 +31,7 @@ script_dir=$(cd $(dirname $0) || exit 1; pwd)
pushd $script_dir/..
mkdir -p dist
DOCKER_ARGS="-v $(pwd)/dist:/work/dist/"
DOCKER_ARGS+=" -e MANYLINUX_VERSION"
/tmp/dockcross-manylinux-x64 \
-a "$DOCKER_ARGS" \
./scripts/internal/manylinux-build-wheels.sh "$@"
Expand Down
Expand Up @@ -5,14 +5,18 @@
#
# Exported variables used in this script:
# - ITK_PACKAGE_VERSION: Tag for ITKPythonBuilds build archive to use
# - TARBALL_SPECIALIZATION: manylinux specialization to use
# Examples: "-manylinux_2_28", "-manylinux2014", "-manylinux_2_28_aarch64"
# Examples: "v5.3.0", "v5.2.1.post1"
# See available tags at https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/tags
# - MANYLINUX_VERSION: manylinux specialization to use
# Examples: "_2_28", "2014", "_2_28_aarch64"
# See https://github.com/dockcross/dockcross
# - ITKPYTHONPACKAGE_TAG: Tag for ITKPythonPackage build scripts to use.
# If ITKPYTHONPACKAGE_TAG is empty then the default scripts distributed
# with the ITKPythonBuilds archive will be used.
# - ITKPYTHONPACKAGE_ORG: Github organization or user to use for ITKPythonPackage
# build script source. Default is InsightSoftwareConsortium.
# Ignored if ITKPYTHONPACKAGE_TAG is empty.
#

# -----------------------------------------------------------------------
# Script argument parsing
Expand Down Expand Up @@ -57,9 +61,14 @@ fi
# Expect unzstd > v1.3.2, see discussion in `dockcross-manylinux-build-tarball.sh`
${unzstd_exe} --version

# -----------------------------------------------------------------------
# Fetch build archive

TARBALL_SPECIALIZATION="-manylinux${MANYLINUX_VERSION:=_2_28}"
TARBALL_NAME="ITKPythonBuilds-linux${TARBALL_SPECIALIZATION}.tar"

if [[ ! -f ${TARBALL_NAME}.zst ]]; then
echo "Fetching https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/${ITK_PACKAGE_VERSION:=v5.3.0}/${TARBALL_NAME}.zst"
curl -L https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/${ITK_PACKAGE_VERSION:=v5.3.0}/${TARBALL_NAME}.zst -O
fi
if [[ ! -f ./${TARBALL_NAME}.zst ]]; then
Expand Down Expand Up @@ -99,8 +108,10 @@ if [[ ! -f ./ITKPythonPackage/scripts/dockcross-manylinux-build-module-wheels.sh
fi
cp -a ITKPythonPackage/oneTBB-prefix ./

# -----------------------------------------------------------------------

set -- "${FORWARD_ARGS[@]}"; # Restore initial argument list
if [[ "${TARBALL_SPECIALIZATION}" = "-manylinux_2_28_aarch64" ]]; then
if [[ "${MANYLINUX_VERSION}" = "_2_28_aarch64" ]]; then
./ITKPythonPackage/scripts/manylinux_2_28_aarch64-build-module-wheels.sh "$@"
else
./ITKPythonPackage/scripts/dockcross-manylinux-build-module-wheels.sh "$@"
Expand Down
2 changes: 1 addition & 1 deletion scripts/internal/manylinux-build-common.sh
Expand Up @@ -80,6 +80,6 @@ if ! type ninja > /dev/null 2>&1; then
popd
fi

MANYLINUX_VERSION=_2_28
MANYLINUX_VERSION=${MANYLINUX_VERSION:=_2_28}

echo "Building wheels for $ARCH using manylinux${MANYLINUX_VERSION}"
10 changes: 10 additions & 0 deletions scripts/internal/manylinux-build-module-wheels.sh
Expand Up @@ -15,6 +15,16 @@
# DOCKER_ARGS="-v /path/to/lib.so:/usr/local/lib64/lib.so"
# /tmp/dockcross-manylinux-x64 -a "$DOCKER_ARGS" manylinux-build-module-wheels.sh
#
# The specialized manylinux container version should be set prior to running this script.
# See https://github.com/dockcross/dockcross for available versions and tags.
#
# For example, `docker run -e <var>` can be used to set an environment variable when launching a container:
#
# export MANYLINUX_VERSION=2014
# docker run --rm dockcross/manylinux${MANYLINUX_VERSION}-x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
# chmod u+x /tmp/dockcross-manylinux-x64
# /tmp/dockcross-manylinux-x64 -e MANYLINUX_VERSION manylinux-build-module-wheels.sh cp39
#

# -----------------------------------------------------------------------
# Script argument parsing
Expand Down
10 changes: 10 additions & 0 deletions scripts/internal/manylinux-build-wheels.sh
Expand Up @@ -15,6 +15,16 @@
# DOCKER_ARGS="-v /path/to/lib.so:/usr/local/lib64/lib.so"
# /tmp/dockcross-manylinux-x64 -a "$DOCKER_ARGS" manylinux-build-wheels.sh
#
# The specialized manylinux container version should be set prior to running this script.
# See https://github.com/dockcross/dockcross for available versions and tags.
#
# For example, `docker run -e <var>` can be used to set an environment variable when launching a container:
#
# export MANYLINUX_VERSION=2014
# docker run --rm dockcross/manylinux${MANYLINUX_VERSION}-x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
# chmod u+x /tmp/dockcross-manylinux-x64
# /tmp/dockcross-manylinux-x64 -e MANYLINUX_VERSION manylinux-build-module-wheels.sh cp39
#

# -----------------------------------------------------------------------
# These variables are set in common script:
Expand Down
14 changes: 11 additions & 3 deletions scripts/manylinux_2_28_aarch64-build-module-wheels.sh
Expand Up @@ -16,9 +16,17 @@
# export LD_LIBRARY_PATH="/path/to/OpenCL.so:/path/to/OpenCL.so.1.2"
# scripts/dockcross-manylinux-build-module-wheels.sh cp39
#
# A specialized manylinux image and tag can be used by exporting to MANYLINUX_VERSION before
# running this script. Default is _2_28_aarch64.
#
# For example,
#
# export MANYLINUX_VERSION=2014
# export IMAGE_TAG=20221108-102ebcc
# scripts/dockcross-manylinux-build-module-wheels.sh cp39

MANYLINUX_VERSION=_2_28
IMAGE_TAG=latest
MANYLINUX_VERSION=${MANYLINUX_VERSION:=_2_28_aarch64}
IMAGE_TAG=${IMAGE_TAG:=latest}

script_dir=$(cd $(dirname $0) || exit 1; pwd)

Expand All @@ -35,4 +43,4 @@ if [[ -n ${LD_LIBRARY_PATH} ]]; then
fi

docker run --privileged --rm tonistiigi/binfmt --install all
docker run --rm -it $DOCKER_ARGS -v $(pwd):/work/ quay.io/pypa/manylinux${MANYLINUX_VERSION}_aarch64:${IMAGE_TAG} "/ITKPythonPackage/scripts/internal/manylinux-aarch64-build-module-wheels.sh" "$@"
docker run --rm -it $DOCKER_ARGS -v $(pwd):/work/ quay.io/pypa/manylinux${MANYLINUX_VERSION}:${IMAGE_TAG} "/ITKPythonPackage/scripts/internal/manylinux-aarch64-build-module-wheels.sh" "$@"

0 comments on commit 583e7a6

Please sign in to comment.