A setup script to generate ITK Python Wheels

Overview

ITK Python Package

This project provides a setup.py script to build ITK Python binary packages and infrastructure to build ITK external module Python packages.

ITK is an open-source, cross-platform system that provides developers with an extensive suite of software tools for image analysis.

Installation

To install the ITK Python package:

    $ pip install itk

Usage

Simple example script

    import itk
    import sys

    input_filename = sys.argv[1]
    output_filename = sys.argv[2]

    image = itk.imread(input_filename)

    median = itk.median_image_filter(image, radius=2)

    itk.imwrite(median, output_filename)

See also the ITK Python Quick Start Guide. There are also many downloadable examples documented in Sphinx.

For more information on ITK's Python wrapping, an introduction is provided in the ITK Software Guide.

Comments
  • Add support for shared libraries dependencies in remote modules

    Add support for shared libraries dependencies in remote modules

    We want to package the OpenCL ICD loader in particular in dependent remote modules.

    We can build on the shared library support in 5.3rc1 for TBB.

    For the platform-specific wheel fix-up tools, auditwheel (Linux), delocate (macOS), delvewheel (Windows) we need to add support for additional shared libraries. Mostly, this should be making the scripts that expose the path to local libraries with environmental variables allow appending to that variable, then set this variable to the path to the OpenCL ICD loader library in the remote module GitHub CI configuration.

    E.g.:

    https://github.com/InsightSoftwareConsortium/ITKPythonPackage/blob/ad3f8d0c3dcb0e1b959924b4ceea8e832d612758/scripts/internal/manylinux-build-module-wheels.sh#L14

    ->

    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/work/oneTBB-prefix/lib64
    

    For Windows:

    https://github.com/InsightSoftwareConsortium/ITKPythonPackage/blob/ad3f8d0c3dcb0e1b959924b4ceea8e832d612758/scripts/windows_build_wheels.py#L225-L228

    We may need to change this script to enable passing addition paths as a CLI argument. Also, we will likely need to adjust the strategy since delvewheel patches itk/__init__.py.

    For macOS:

    https://github.com/InsightSoftwareConsortium/ITKPythonPackage/blob/ad3f8d0c3dcb0e1b959924b4ceea8e832d612758/scripts/macpython-build-module-wheels.sh#L29

    opened by thewtex 17
  • Source path directory too long

    Source path directory too long

    When attempting to install via the pip: pip install itk

    I receive the following error:

    ITK source code directory path length is too long (${n} > 50).
    Please move the ITK source code directory to a directory with a shorter path.
    

    According to this article (https://public.kitware.com/pipermail/community/2013-December/004475.html), the check is due to Visual Studio and truncation of commands.

    Is there a way to specify the build and install directory? In addition, the build files in skbuild are fairly long as it is so I could only place the ITKPythonPackage directory in my D: drive for it to work.

    If there is not a way to specify the build and install directory, I propose this option be added and documentation be added to the front page.

    opened by addisonElliott 14
  • COMP: Ensure tbb library is built with the expected deployment target

    COMP: Ensure tbb library is built with the expected deployment target

    This commit is a follow-up of these commits:

    • a5f774ba5 (ENH: Add TBB support to Linux wheels)
    • 374c744a1 (ENH: Add macOS wheel TBB support)
    • 037a326c1 (ENH: Build macOS module wheels with TBB support)

    It ensures that oneTBB is built specifying the non-default options expected by oneTBB ^1 and it should ensure the library can be loaded on macOS >= 10.9.

    See https://discourse.itk.org/t/itk-5-3rc4-post3-failure-to-load-libtbb-library-observed-on-macos-10-13/5405/1#suggested-path-forward-3

    opened by jcfr 13
  • delocate is failing on Python files

    delocate is failing on Python files

    Interestingly, delocate-listdeps has recently started to fail when building module packages:

    +/Users/Kitware/Dashboards/ITK/ITKPythonPackage/scripts/../venvs/2.7/bin/delocate-listdeps /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp27-cp27m-macosx_10_6_x86_64.whl /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp34-cp34m-macosx_10_6_x86_64.whl /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp35-cp35m-macosx_10_6_x86_64.whl /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp36-cp36m-macosx_10_6_x86_64.whl
    /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp27-cp27m-macosx_10_6_x86_64.whl:
    Traceback (most recent call last):
      File "/Users/Kitware/Dashboards/ITK/ITKPythonPackage/scripts/../venvs/2.7/bin/delocate-listdeps", line 61, in <module>
        main()
      File "/Users/Kitware/Dashboards/ITK/ITKPythonPackage/scripts/../venvs/2.7/bin/delocate-listdeps", line 44, in main
        lib_dict = wheel_libs(path)
      File "/Users/kitware/Dashboards/ITK/ITKPythonPackage/venvs/2.7/lib/python2.7/site-packages/delocate/libsana.py", line 161, in wheel_libs
        lib_dict = tree_libs(tmpdir, filt_func)
      File "/Users/kitware/Dashboards/ITK/ITKPythonPackage/venvs/2.7/lib/python2.7/site-packages/delocate/libsana.py", line 54, in tree_libs
        for install_name in get_install_names(depending_libpath):
      File "/Users/kitware/Dashboards/ITK/ITKPythonPackage/venvs/2.7/lib/python2.7/site-packages/delocate/tools.py", line 173, in get_install_names
        if not _line0_says_object(lines[0], filename):
      File "/Users/kitware/Dashboards/ITK/ITKPythonPackage/venvs/2.7/lib/python2.7/site-packages/delocate/tools.py", line 143, in _line0_says_object
        raise InstallNameError('Unexpected first line: ' + line0)
    delocate.tools.InstallNameError: Unexpected first line: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: '/private/var/folders/bb/n7t3rs157850byt_jfdcq9k80000gn/T/tmp_NF5m6/itk/itkFourierStripeArtifactImageFilterPython.py': The file was not recognized as a valid object file
    

    CC: @jcfr @matthew-brett

    opened by thewtex 10
  • Add support for multiple manylinux versions

    Add support for multiple manylinux versions

    Motivation for this change is to build wheels with C++ ABI compatible with Slicer built using newer g++ having _GLIBCXX_USE_CXX11_ABI defaulting to 1.

    See https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

    Note that the latest Slicer release (5.0) is built using centos7 based ^1 environment having _GLIBCXX_USE_CXX11_ABI set to 0.

    We should likely build wheels using both manylinux2014 and manylinux_2_28.

    As of 2022.06.22, this pull-request uses 2_24, as commented ^2 by @henryiii, I will instead update dockcross ^3 to add 2_28 based image (instead of 2_24).

    References:

    • https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
    • https://discuss.python.org/t/how-to-set-glibcxx-use-cxx11-abi-for-manylinux2014-and-manylinux2010-wheels/10551
    • https://github.com/pytorch/pytorch/issues/51039
    • https://github.com/pypa/manylinux/issues/1012
    • https://github.com/dockcross/dockcross/pull/705
    opened by jcfr 9
  • itkHelpers.py missing in itk python 5.2.0

    itkHelpers.py missing in itk python 5.2.0

    Unable to find itkHelpers.py in the installation and got python error: ModuleNotFoundError: No module named 'itkHelpers'

    itk python 5.2.0 installed via pip install itk

    opened by yliu7366 8
  • import _ITKPyBasePython failed

    import _ITKPyBasePython failed

    my Env: win10 64 bits python 3.6 itk 5.1.0

    my err: File "C:\Users\haoch\AppData\Local\Programs\Python\Python36\lib\site-packages\itk\Configuration..\ITKPyBasePython.py", line 15, in import _ITKPyBasePython ImportError: DLL load failed:

    when I use itk.imread(path),then the error occured what can I do?

    opened by xiaoxifei1223 8
  • Latest manylinux images missing `sudo`

    Latest manylinux images missing `sudo`

    Summary

    Local and CI tests in relation to https://github.com/InsightSoftwareConsortium/ITKPythonPackage/pull/233 fail to build on Linux. The issue appears to originate from the dockcross manylinux image.

    Observed behavior

    Building wheels for x64 using manylinux_2_28
    ++ type ninja
    ++ MANYLINUX_VERSION=_2_28
    ++ echo 'Building wheels for x64 using manylinux_2_28'
    + sudo ldconfig
    /opt/rh/gcc-toolset-12/root/usr/bin/sudo: line 41: /usr/bin/sudo: No such file or directory
    Error: Process completed with exit code 127.
    

    See log: https://github.com/InsightSoftwareConsortium/ITKSplitComponents/actions/runs/3583756532/jobs/6029570633

    Expected behavior

    Build succeeds.

    Steps to Reproduce

    > MANYLINUX_VERSION=_2_28
    > IMAGE_TAG=20221128-2024e4b
    
    # Generate dockcross scripts
    > docker run --rm dockcross/manylinux${MANYLINUX_VERSION}-x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
    > chmod u+x /tmp/dockcross-manylinux-x64
    
    # Launch container
    > /tmp/dockcross-manylinux-x64 bash
    
    # Try to run any command with sudo
    >> sudo ldconfig
    /opt/rh/gcc-toolset-12/root/usr/bin/sudo: line 41: /usr/bin/sudo: No such file or directory
    
    # Try to find sudo in /usr/bin
    >> ls /usr/bin | grep sudo
    # no results
    

    Other Notes

    Possibly related to the most recent image tag update: https://github.com/InsightSoftwareConsortium/ITKPythonPackage/pull/230

    Investigation shows that sudo works in the previous dockcross image:

    > IMAGE_TAG=20221108-102ebcc
    > 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 bash
    >> sudo ldconfig
    >> sudo echo "sudo works"
    sudo works
    
    opened by tbirdso 6
  • ENH: Add build script update step to download script

    ENH: Add build script update step to download script

    Several related updates:

    • Adds update step to apply build script patches to ITKPythonBuilds packages
    • Exposes manylinux parameters and resolves issue where wrong image was used with specialized tarballs
    • Reverts manylinux image tag while awaiting fix for sudo issue tracked in https://github.com/InsightSoftwareConsortium/ITKPythonPackage/issues/235 and https://github.com/dockcross/dockcross/issues/746

    These changes are tested at https://github.com/InsightSoftwareConsortium/ITKSplitComponents/actions/runs/3586129456

    opened by tbirdso 6
  • CMake version ignored

    CMake version ignored

    Despite explicitly getting CMake 3.24 in the CI, an older version is used during some stage resulting in insufficient version error:

    -- Configuring done
    -- Generating done
    -- Build files have been written to: /work/_cmake_test_compile/build
    CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
      CMake 3.24 or higher is required.  You are running version 3.23.1
    
    
    -- Configuring incomplete, errors occurred!
      File "/opt/python/cp38-cp38/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 544, in setup
        env = cmkr.configure(cmake_args,
      File "/opt/python/cp38-cp38/lib/python3.8/site-packages/skbuild/cmaker.py", line 221, in configure
        raise SKBuildError(
    An error occurred while configuring with CMake.
      Command:
    
        "cmake" "/work" "-G" "Ninja" "-DCMAKE_INSTALL_PREFIX:PATH=/work/_skbuild/linux-x86_64-3.8/cmake-install" "-DPYTHON_EXECUTABLE:FILEPATH=/opt/python/cp38-cp38/bin/python" "-DPYTHON_VERSION_STRING:STRING=3.8.13" "-DPYTHON_INCLUDE_DIR:PATH=/opt/_internal/cpython-3.8.13/include/python3.8" "-DPYTHON_LIBRARY:FILEPATH=libpython3.8.a" "-DSKBUILD:BOOL=TRUE" "-DCMAKE_MODULE_PATH:PATH=/opt/python/cp38-cp38/lib/python3.8/site-packages/skbuild/resources/cmake" "-DITK_DIR:PATH=/work/ITK-cp38-cp38-manylinux_2_28_x64" "-DITK_USE_SYSTEM_SWIG:BOOL=ON" "-DWRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel" "-DSWIG_EXECUTABLE:FILEPATH=/work/ITK-cp38-cp38-manylinux_2_28_x64/Wrapping/Generators/SwigInterface/swig/bin/swig" "-DCMAKE_CXX_COMPILER_TARGET:STRING=x86_64-linux-gnu" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DBUILD_TESTING:BOOL=OFF" "-DPython3_EXECUTABLE:FILEPATH=/opt/python/cp38-cp38/bin/python" "-DPython3_INCLUDE_DIR:PATH=/opt/python/cp38-cp38/bin/../include/python3.8" "-DCMAKE_BUILD_TYPE:STRING=Release"
    

    This might be a problem in https://github.com/python-cmake-buildsystem/python-cmake-buildsystem.

    opened by dzenanz 6
  • TimeVaryingDiffeomorphisms in ITKPythonPackage

    TimeVaryingDiffeomorphisms in ITKPythonPackage

    Hello I wanted to know if the itkpythonpackage provides bindings for the deformable registration components of itk. So far i havent found this using google search.

    Thansk

    opened by cakeinspace 6
  • COMP: Consolidate Linux ARM build script

    COMP: Consolidate Linux ARM build script

    Several quality-of-life fixes and updates for ARM support:

    • Consolidates ARM module script with x86_64 module script for easier maintenance and comparison between procedures. Internal ARM script is preserved as a wrapper around generic internal build script.
    • Splits MANYLINUX_VERSION variable into MANYLINUX_VERSION prefix and TARGET_ARCH postfix to better reflect available images.
    • Uses sudo to avoid permissions failure when running docker or cleaning up files on ARM systems

    Applies changes introduced by @thewtex in https://github.com/InsightSoftwareConsortium/ITKPythonPackage/pull/234.

    Tests have passed at https://github.com/InsightSoftwareConsortium/ITKSplitComponents/actions/runs/3736106376/jobs/6340059855. Note that ARM builds on Github Actions runners are significantly slower than x86/x64 builds due to emulation. ITKSplitComponents Linux jobs previously completed in ~10 minutes and now complete in ~30 minutes with the addition of ARM wheels.

    co-authored-by: Matt McCormick [email protected]

    opened by tbirdso 9
  • fail to build release 5.2rc03 on ArchLinux

    fail to build release 5.2rc03 on ArchLinux

    Error log:

    CMake Error at Wrapping/CMakeUtilityFunctions.cmake:40 (math):
      math cannot parse the expression: ")
    
      set(ITK_WRAP_VECTOR_COMPONENTS + 1": syntax error, unexpected
      exp_CLOSEPARENT (1).
    Call Stack (most recent call first):
      Wrapping/WrapBasicTypes.cmake:55 (INCREMENT)
      Wrapping/ConfigureWrapping.cmake:131 (include)
      Wrapping/CMakeLists.txt:97 (include)
    
    
    CMake Warning (dev) at Wrapping/CMakeUtilityFunctions.cmake:40 (math):
      Unexpected character in expression at position 1: "
    
    Call Stack (most recent call first):
      Wrapping/WrapBasicTypes.cmake:63 (INCREMENT)
      Wrapping/ConfigureWrapping.cmake:131 (include)
      Wrapping/CMakeLists.txt:97 (include)
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    CMake Error at Wrapping/WrapBasicTypes.cmake:73 (message):
      ITK_WRAP_VECTOR_COMPONENTS must include ITK_WRAP_IMAGE_DIMS
    Call Stack (most recent call first):
      Wrapping/ConfigureWrapping.cmake:131 (include)
      Wrapping/CMakeLists.txt:97 (include)
    

    See the complete build log here

    opened by hubutui 20
Releases(v5.3.0)
Owner
Insight Software Consortium
Community development of the Insight Toolkit (ITK)
Insight Software Consortium
Code for our paper A Transformer-Based Feature Segmentation and Region Alignment Method For UAV-View Geo-Localization,

FSRA This repository contains the dataset link and the code for our paper A Transformer-Based Feature Segmentation and Region Alignment Method For UAV

Dmmm 32 Dec 18, 2022
Few-NERD: Not Only a Few-shot NER Dataset

Few-NERD: Not Only a Few-shot NER Dataset This is the source code of the ACL-IJCNLP 2021 paper: Few-NERD: A Few-shot Named Entity Recognition Dataset.

THUNLP 319 Dec 30, 2022
Unofficial implementation of Google "CutPaste: Self-Supervised Learning for Anomaly Detection and Localization" in PyTorch

CutPaste CutPaste: image from paper Unofficial implementation of Google's "CutPaste: Self-Supervised Learning for Anomaly Detection and Localization"

Lilit Yolyan 59 Nov 27, 2022
Learning to Communicate with Deep Multi-Agent Reinforcement Learning in PyTorch

Learning to Communicate with Deep Multi-Agent Reinforcement Learning This is a PyTorch implementation of the original Lua code release. Overview This

Minqi 297 Dec 12, 2022
OpenDILab Multi-Agent Environment

Go-Bigger: Multi-Agent Decision Intelligence Environment GoBigger Doc (中文版) Ongoing 2021.11.13 We are holding a competition —— Go-Bigger: Multi-Agent

OpenDILab 441 Jan 05, 2023
Secure Distributed Training at Scale

Secure Distributed Training at Scale This repository contains the implementation of experiments from the paper "Secure Distributed Training at Scale"

Yandex Research 9 Jul 11, 2022
Code for GNMR in ICDE 2021

GNMR Code for GNMR in ICDE 2021 Please unzip data files in Datasets/MultiInt-ML10M first. Run labcode_preSamp.py (with graph sampling) for ECommerce-c

7 Oct 27, 2022
Using Clinical Drug Representations for Improving Mortality and Length of Stay Predictions

Using Clinical Drug Representations for Improving Mortality and Length of Stay Predictions Usage Clone the code to local. https://github.com/tanlab/MI

Computational Biology and Machine Learning lab @ TOBB ETU 3 Oct 18, 2022
Simple sinc interpolation in PyTorch.

Kazane: simple sinc interpolation for 1D signal in PyTorch Kazane utilize FFT based convolution to provide fast sinc interpolation for 1D signal when

Chin-Yun Yu 10 May 03, 2022
Revisiting Weakly Supervised Pre-Training of Visual Perception Models

SWAG: Supervised Weakly from hashtAGs This repository contains SWAG models from the paper Revisiting Weakly Supervised Pre-Training of Visual Percepti

Meta Research 134 Jan 05, 2023
Annealed Flow Transport Monte Carlo

Annealed Flow Transport Monte Carlo Open source implementation accompanying ICML 2021 paper by Michael Arbel*, Alexander G. D. G. Matthews* and Arnaud

DeepMind 30 Nov 21, 2022
GeoMol: Torsional Geometric Generation of Molecular 3D Conformer Ensembles

GeoMol: Torsional Geometric Generation of Molecular 3D Conformer Ensembles This repository contains a method to generate 3D conformer ensembles direct

127 Dec 20, 2022
Converts given image (png, jpg, etc) to amogus gif.

Image to Amogus Converter Converts given image (.png, .jpg, etc) to an amogus gif! Usage Place image in the /target/ folder (or anywhere realistically

Hank Magan 1 Nov 24, 2021
Facial Action Unit Intensity Estimation via Semantic Correspondence Learning with Dynamic Graph Convolution

FAU Implementation of the paper: Facial Action Unit Intensity Estimation via Semantic Correspondence Learning with Dynamic Graph Convolution. Yingruo

Evelyn 78 Nov 29, 2022
Tensorflow 2.x based implementation of EDSR, WDSR and SRGAN for single image super-resolution

Single Image Super-Resolution with EDSR, WDSR and SRGAN A Tensorflow 2.x based implementation of Enhanced Deep Residual Networks for Single Image Supe

Martin Krasser 1.3k Jan 06, 2023
Minimalistic PyTorch training loop

Backbone for PyTorch training loop Will try to keep it minimalistic. pip install back from back import Bone Features Progress bar Checkpoints saving/l

Kashin 4 Jan 16, 2020
Clustering with variational Bayes and population Monte Carlo

pypmc pypmc is a python package focusing on adaptive importance sampling. It can be used for integration and sampling from a user-defined target densi

45 Feb 06, 2022
Modular Gaussian Processes

Modular Gaussian Processes for Transfer Learning 🧩 Introduction This repository contains the implementation of our paper Modular Gaussian Processes f

Pablo Moreno-Muñoz 10 Mar 15, 2022
ViDT: An Efficient and Effective Fully Transformer-based Object Detector

ViDT: An Efficient and Effective Fully Transformer-based Object Detector by Hwanjun Song1, Deqing Sun2, Sanghyuk Chun1, Varun Jampani2, Dongyoon Han1,

NAVER AI 262 Dec 27, 2022
Share a benchmark that can easily apply reinforcement learning in Job-shop-scheduling

Gymjsp Gymjsp is an open source Python library, which uses the OpenAI Gym interface for easily instantiating and interacting with RL environments, and

134 Dec 08, 2022