Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ lib
lib64
MANIFEST
oneTBB-prefix/
pyproject.toml

# Installer logs
pip-log.txt
Expand Down
16 changes: 9 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ if(ITKPythonPackage_SUPERBUILD)
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
)
endif()
set(ep_download_extract_timestamp_arg )
if(CMAKE_VERSION VERSION_EQUAL "3.24" OR CMAKE_VERSION VERSION_GREATER "3.24")
# See https://cmake.org/cmake/help/latest/policy/CMP0135.html
set(ep_download_extract_timestamp_arg DOWNLOAD_EXTRACT_TIMESTAMP 1)
endif()

#-----------------------------------------------------------------------------
# Options
Expand Down Expand Up @@ -89,8 +94,8 @@ if(ITKPythonPackage_SUPERBUILD)

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

# ITK release 2023-10-11
set(ITK_GIT_TAG "v5.4rc02")
# master branch, 2024-04-04
set(ITK_GIT_TAG "4449a99921a72ac6ceb4f8fa4521c6b6db6cbfe1")

#-----------------------------------------------------------------------------
# A separate project is used to download ITK, so that it can reused
Expand Down Expand Up @@ -124,6 +129,7 @@ if(ITKPythonPackage_SUPERBUILD)
-DCMAKE_INSTALL_LIBDIR:STRING=lib # Skip default initialization by GNUInstallDirs CMake module
${ep_common_cmake_cache_args}
${tbb_cmake_cache_args}
${ep_download_extract_timestamp_arg}
-DCMAKE_BUILD_TYPE:STRING=Release
BUILD_BYPRODUCTS "${TBB_DIR}/TBBConfig.cmake"
USES_TERMINAL_DOWNLOAD 1
Expand Down Expand Up @@ -276,18 +282,14 @@ if(ITKPythonPackage_SUPERBUILD)
-DWRAP_ITK_INSTALL_COMPONENT_PER_MODULE:BOOL=${install_component_per_module}
-DITK_LEGACY_SILENT:BOOL=ON
-DITK_WRAP_PYTHON:BOOL=ON
-DITK_WRAP_unsigned_short:BOOL=ON
-DITK_WRAP_double:BOOL=ON
-DITK_WRAP_complex_double:BOOL=ON
-DITK_WRAP_IMAGE_DIMS:STRING=2;3;4
-DITK_WRAP_DOC:BOOL=ON
-DDOXYGEN_EXECUTABLE:FILEPATH=${DOXYGEN_EXECUTABLE}
-DPython3_INCLUDE_DIR:PATH=${Python3_INCLUDE_DIR}
-DPython3_LIBRARY:FILEPATH=${Python3_LIBRARY}
-DPython3_EXECUTABLE:FILEPATH=${Python3_EXECUTABLE}
${ep_common_cmake_cache_args}
${tbb_args}
${ep_itk_cmake_cache_args}
${ep_download_extract_timestamp_arg}
USES_TERMINAL_DOWNLOAD 1
USES_TERMINAL_UPDATE 1
USES_TERMINAL_CONFIGURE 1
Expand Down
8 changes: 0 additions & 8 deletions MANIFEST.in

This file was deleted.

1 change: 0 additions & 1 deletion itk/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion itkVersion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = '5.4rc2'
VERSION = '5.4rc3'

def get_versions():
"""Returns versions for the ITK Python package.
Expand Down
7 changes: 5 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
ninja==1.11.1
scikit-build==0.17.6
ninja==1.11.1.1
scikit-build-core==0.8.2
build==1.2.1
pyproject-metadata
pathspec
9 changes: 6 additions & 3 deletions scripts/dockcross-manylinux-build-module-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
# Handle case where the script directory is not the working directory
script_dir=$(cd $(dirname $0) || exit 1; pwd)
source "${script_dir}/dockcross-manylinux-set-vars.sh"
source "${script_dir}/oci_exe.sh"

oci_exe=$(ociExe)

if [[ -n ${ITK_MODULE_PREQ} ]]; then
echo "Building module dependencies ${ITK_MODULE_PREQ}"
Expand Down Expand Up @@ -81,14 +84,14 @@ if [[ "${TARGET_ARCH}" = "aarch64" ]]; then
docker_prefix="sudo"
fi

${docker_prefix} docker run --privileged --rm tonistiigi/binfmt --install all
${docker_prefix} $oci_exe run --privileged --rm tonistiigi/binfmt --install all

# Build wheels
DOCKER_ARGS+=" -v $(pwd):/work/ --rm"
${docker_prefix} docker run $DOCKER_ARGS ${CONTAINER_SOURCE} "/ITKPythonPackage/scripts/internal/manylinux-aarch64-build-module-wheels.sh" "$@"
${docker_prefix} $oci_exe run $DOCKER_ARGS ${CONTAINER_SOURCE} "/ITKPythonPackage/scripts/internal/manylinux-aarch64-build-module-wheels.sh" "$@"
else
# Generate dockcross scripts
docker run --rm ${CONTAINER_SOURCE} > /tmp/dockcross-manylinux-x64
$oci_exe run --rm ${CONTAINER_SOURCE} > /tmp/dockcross-manylinux-x64
chmod u+x /tmp/dockcross-manylinux-x64

# Build wheels
Expand Down
1 change: 1 addition & 0 deletions scripts/dockcross-manylinux-build-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ fi
tar -c --to-stdout \
ITKPythonPackage/ITK-* \
ITKPythonPackage/oneTBB* \
ITKPythonPackage/requirements-dev.txt \
ITKPythonPackage/scripts > ITKPythonBuilds-linux.tar
$zstd_exe -f \
-10 \
Expand Down
12 changes: 7 additions & 5 deletions scripts/dockcross-manylinux-build-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@
# export IMAGE_TAG=20221205-459c9f0
# scripts/dockcross-manylinux-build-module-wheels.sh cp39
#
script_dir=$(cd $(dirname $0) || exit 1; pwd)
source "${script_dir}/oci_exe.sh"

oci_exe=$(ociExe)

MANYLINUX_VERSION=${MANYLINUX_VERSION:=_2_28}

if [[ ${MANYLINUX_VERSION} == _2_28 ]]; then
IMAGE_TAG=${IMAGE_TAG:=20230926-9eb419c}
IMAGE_TAG=${IMAGE_TAG:=20240304-9e57d2b}
elif [[ ${MANYLINUX_VERSION} == 2014 ]]; then
IMAGE_TAG=${IMAGE_TAG:=20230926-9eb419c}
IMAGE_TAG=${IMAGE_TAG:=20240304-9e57d2b}
else
echo "Unknown manylinux version ${MANYLINUX_VERSION}"
exit 1;
fi

# Generate dockcross scripts
docker run --rm dockcross/manylinux${MANYLINUX_VERSION}-x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
$oci_exe run --rm docker.io/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)

# Build wheels
pushd $script_dir/..
mkdir -p dist
Expand Down
8 changes: 4 additions & 4 deletions scripts/dockcross-manylinux-set-vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ TARGET_ARCH=${TARGET_ARCH:=x64}

# Specialized manylinux image tag to use for building.
if [[ ${MANYLINUX_VERSION} == _2_28 && ${TARGET_ARCH} == x64 ]]; then
IMAGE_TAG=${IMAGE_TAG:=20230926-9eb419c}
IMAGE_TAG=${IMAGE_TAG:=20240304-9e57d2b}
elif [[ ${MANYLINUX_VERSION} == _2_28 && ${TARGET_ARCH} == aarch64 ]]; then
IMAGE_TAG=${IMAGE_TAG:=2022-11-19-1b19e81}
IMAGE_TAG=${IMAGE_TAG:=2024-03-25-9206bd9}
elif [[ ${MANYLINUX_VERSION} == 2014 ]]; then
IMAGE_TAG=${IMAGE_TAG:=20230926-9eb419c}
IMAGE_TAG=${IMAGE_TAG:=20240304-9e57d2b}
else
echo "Unknown manylinux version ${MANYLINUX_VERSION}"
exit 1;
Expand All @@ -52,7 +52,7 @@ fi
# Set container for requested version/arch/tag.
if [[ ${TARGET_ARCH} == x64 ]]; then
MANYLINUX_IMAGE_NAME=${MANYLINUX_IMAGE_NAME:="manylinux${MANYLINUX_VERSION}-${TARGET_ARCH}:${IMAGE_TAG}"}
CONTAINER_SOURCE="dockcross/${MANYLINUX_IMAGE_NAME}"
CONTAINER_SOURCE="docker.io/dockcross/${MANYLINUX_IMAGE_NAME}"
elif [[ ${TARGET_ARCH} == aarch64 ]]; then
MANYLINUX_IMAGE_NAME=${MANYLINUX_IMAGE_NAME:="manylinux${MANYLINUX_VERSION}_${TARGET_ARCH}:${IMAGE_TAG}"}
CONTAINER_SOURCE="quay.io/pypa/${MANYLINUX_IMAGE_NAME}"
Expand Down
2 changes: 1 addition & 1 deletion scripts/internal/manylinux-aarch64-build-module-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Run this script inside a dockcross container to build Python wheels for an aarch ITK module.
cd /work
yum -y install sudo
yum -y install sudo ninja-build
/opt/python/cp39-cp39/bin/python -m pip install -r /ITKPythonPackage/requirements-dev.txt
for PYBIN in "${PYBINARIES[@]}"; do
${PYBIN}/pip install -r /ITKPythonPackage/requirements-dev.txt
Expand Down
2 changes: 1 addition & 1 deletion scripts/internal/manylinux-build-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [[ $# -eq 0 ]]; then
PYBIN=(/opt/python/*/bin)
PYBINARIES=()
for version in "${PYBIN[@]}"; do
if [[ ${version} == *"cp38"* || ${version} == *"cp39"* || ${version} == *"cp310"* || ${version} == *"cp311"* || ${version} == *"cp312"* ]]; then
if [[ ${version} == *"cp38"* || ${version} == *"cp39"* || ${version} == *"cp310"* || ${version} == *"cp311"* ]]; then
PYBINARIES+=(${version})
fi
done
Expand Down
67 changes: 49 additions & 18 deletions scripts/internal/manylinux-build-module-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ usage()
echo "Usage:
manylinux-build-module-wheels
[ -h | --help ] show usage
[ -c | --cmake_options ] space-separated string of CMake options to forward to the module (e.g. \"-DBUILD_TESTING=OFF\")
[ -c | --cmake_options ] space-separated string of CMake options to forward to the module (e.g. \"--config-setting=cmake.define.BUILD_TESTING=OFF\")
[ -x | --exclude_libs ] semicolon-separated library names to exclude when repairing wheel (e.g. \"libcuda.so\")
[ python_version ] build wheel for a specific python version. (e.g. cp39)"
exit 2
Expand Down Expand Up @@ -73,8 +73,11 @@ source "${script_dir}/manylinux-build-common.sh"
sudo ldconfig
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/work/oneTBB-prefix/lib:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64

# Swig pre-built version from ITK build in ITKPythonPackage
SWIG_VERSION=4.0.2
if test -e setup.py; then
use_skbuild_classic=true
else
use_skbuild_classic=false
fi

# Compile wheels re-using standalone project and archive cache
for PYBIN in "${PYBINARIES[@]}"; do
Expand All @@ -85,6 +88,11 @@ for PYBIN in "${PYBINARIES[@]}"; do
echo "Python3_EXECUTABLE:${Python3_EXECUTABLE}"
echo "Python3_INCLUDE_DIR:${Python3_INCLUDE_DIR}"

if $use_skbuild_classic; then
# So older remote modules with setup.py continue to work
${Python3_EXECUTABLE} -m pip install --upgrade scikit-build
fi

if [[ -e /work/requirements-dev.txt ]]; then
${PYBIN}/pip install --upgrade -r /work/requirements-dev.txt
elif [[ -e /ITKPythonPackage/requirements-dev.txt ]]; then
Expand All @@ -105,21 +113,42 @@ for PYBIN in "${PYBINARIES[@]}"; do
echo 'ITK source tree not available!' 1>&2
exit 1
fi
swig_args=""
if [[ "${ARCH}" = "x64" ]]; then
swig_args="-DITK_USE_SYSTEM_SWIG:BOOL=ON -DSWIG_VERSION:STRING=${SWIG_VERSION} -DSWIG_EXECUTABLE:FILEPATH=${itk_build_dir}/Wrapping/Generators/SwigInterface/swiglinux-${SWIG_VERSION}/bin/swig -DSWIG_DIR:FILEPATH=${itk_build_dir}/Wrapping/Generators/SwigInterface/swiglinux-${SWIG_VERSION}/share/swig/${SWIG_VERSION}"
if $use_skbuild_classic; then
${PYBIN}/python setup.py clean
${PYBIN}/python setup.py bdist_wheel --build-type Release -G Ninja -- \
-DITK_DIR:PATH=${itk_build_dir} \
-DWRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel \
-DCMAKE_CXX_COMPILER_TARGET:STRING=$(uname -m)-linux-gnu \
-DCMAKE_INSTALL_LIBDIR:STRING=lib \
-DBUILD_TESTING:BOOL=OFF \
-DPython3_EXECUTABLE:FILEPATH=${Python3_EXECUTABLE} \
-DPython3_INCLUDE_DIR:PATH=${Python3_INCLUDE_DIR} \
${CMAKE_OPTIONS} \
|| exit 1
else
py_minor=$(echo $version | cut -d '-' -f 1 | cut -d '3' -f 2)
wheel_py_api=""
if test $py_minor -ge 11; then
wheel_py_api=cp3$py_minor
fi
${PYBIN}/python -m build \
--verbose \
--wheel \
--outdir dist \
--no-isolation \
--skip-dependency-check \
--config-setting=cmake.define.ITK_DIR:PATH=${itk_build_dir} \
--config-setting=cmake.define.WRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel \
--config-setting=cmake.define.CMAKE_CXX_COMPILER_TARGET:STRING=$(uname -m)-linux-gnu \
--config-setting=cmake.define.CMAKE_INSTALL_LIBDIR:STRING=lib \
--config-setting=cmake.define.PY_SITE_PACKAGES_PATH:PATH="." \
--config-setting=wheel.py-api=$wheel_py_api \
--config-setting=cmake.define.BUILD_TESTING:BOOL=OFF \
--config-setting=cmake.define.Python3_EXECUTABLE:FILEPATH=${Python3_EXECUTABLE} \
--config-setting=cmake.define.Python3_INCLUDE_DIR:PATH=${Python3_INCLUDE_DIR} \
${CMAKE_OPTIONS} \
|| exit 1
fi
${PYBIN}/python setup.py clean
${PYBIN}/python setup.py bdist_wheel --build-type Release -G Ninja -- \
-DITK_DIR:PATH=${itk_build_dir} \
-DWRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel \
-DCMAKE_CXX_COMPILER_TARGET:STRING=$(uname -m)-linux-gnu \
-DCMAKE_INSTALL_LIBDIR:STRING=lib \
-DBUILD_TESTING:BOOL=OFF \
-DPython3_EXECUTABLE:FILEPATH=${Python3_EXECUTABLE} \
-DPython3_INCLUDE_DIR:PATH=${Python3_INCLUDE_DIR} \
${swig_args} ${CMAKE_OPTIONS} \
|| exit 1
done

# Convert list of excluded libs in --exclude_libs to auditwheel --exclude options
Expand All @@ -130,7 +159,9 @@ fi
sudo ${Python3_EXECUTABLE} -m pip install auditwheel
for whl in dist/*linux*$(uname -m).whl; do
auditwheel repair ${whl} -w /work/dist/ ${AUDITWHEEL_EXCLUDE_ARGS}
rm ${whl}
if $use_skbuild_classic; then
rm ${whl}
fi
done

if compgen -G "dist/itk*-linux*.whl" > /dev/null; then
Expand Down
Loading