How to build python module?

I need to use ITKTwoProjectionRegistration with python3.9, however, the binary wheel from pypi only support for python<=3.8. So I tried to build it myself following this tutorial

I have successfully download docker then run

cd ~/ITKTwoProjectionRegistration
git clone https://github.com/InsightSoftwareConsortium/ITKPythonPackage
./ITKPythonPackage/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh

But the build failed, here is complete output of terminal:

USER:~/ITKTwoProjectionRegistration$ sudo ./ITKPythonPackage/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh 
Fetching https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/v5.3.0/scripts/dockcross-manylinux-download-cache.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
chmod: cannot access 'dockcross-manylinux-download-cache.sh': No such file or directory
./ITKPythonPackage/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh: line 69: ./dockcross-manylinux-download-cache.sh: No such file or directory
Building module wheels
Unable to find image 'dockcross/manylinux_2_28-x64:20230106-1aeaea0' locally
20230106-1aeaea0: Pulling from dockcross/manylinux_2_28-x64
3239c63efc84: Pulling fs layer
772270f4eeb0: Pulling fs layer
1bd9763c7560: Pulling fs layer
f912493fbc67: Pulling fs layer
e67bb4903160: Pulling fs layer
c56f03bb6bc0: Pulling fs layer
832c2a8e4491: Pulling fs layer
7c221cd720fe: Pulling fs layer
1b8dfe99e183: Pulling fs layer
39f0ea08a76c: Pulling fs layer
391f21a370b4: Pulling fs layer
e2bcfc885f2b: Pulling fs layer
d1d7a8c7ae1a: Pulling fs layer
f6108b8daef2: Pulling fs layer
f2c32ff93f39: Pulling fs layer
e67bb4903160: Waiting
4f4fb700ef54: Pulling fs layer
908fbf41b45c: Pulling fs layer
872e27585d51: Pulling fs layer
fb4a0c119ee2: Pulling fs layer
b4dcc75110d7: Pulling fs layer
bd37f4e53a35: Pulling fs layer
a3ee60d1d341: Pulling fs layer
10e63d14836d: Pulling fs layer
e39bf648123d: Pulling fs layer
c56f03bb6bc0: Waiting
587184fb8579: Pulling fs layer
832c2a8e4491: Waiting
d1d7a8c7ae1a: Waiting
c811e73378a6: Pulling fs layer
ecc79205ba48: Pulling fs layer
f6108b8daef2: Waiting
872e27585d51: Waiting
f2c32ff93f39: Waiting
4f4fb700ef54: Waiting
bd37f4e53a35: Waiting
5444d52fe7f0: Pulling fs layer
e39bf648123d: Waiting
f912493fbc67: Waiting
636e17929669: Pulling fs layer
1771c20fe4c0: Pulling fs layer
587184fb8579: Waiting
71aac75e819e: Pulling fs layer
786317a2edc0: Pulling fs layer
a3ee60d1d341: Waiting
84324f7d8f77: Pulling fs layer
33642bd99cc8: Pulling fs layer
10e63d14836d: Waiting
e2bcfc885f2b: Waiting
1b8dfe99e183: Waiting
c811e73378a6: Waiting
37533d5ff3c0: Pulling fs layer
2c4eb121e2f2: Pulling fs layer
391f21a370b4: Waiting
33642bd99cc8: Waiting
b4dcc75110d7: Waiting
de5c4f67a60b: Pulling fs layer
71aac75e819e: Waiting
5444d52fe7f0: Waiting
37533d5ff3c0: Waiting
1771c20fe4c0: Waiting
84324f7d8f77: Waiting
de5c4f67a60b: Waiting
fb4a0c119ee2: Waiting
39f0ea08a76c: Waiting
2c4eb121e2f2: Waiting
786317a2edc0: Waiting
ecc79205ba48: Waiting
772270f4eeb0: Download complete
1bd9763c7560: Verifying Checksum
1bd9763c7560: Download complete
f912493fbc67: Verifying Checksum
f912493fbc67: Download complete
e67bb4903160: Verifying Checksum
e67bb4903160: Download complete
c56f03bb6bc0: Download complete
7c221cd720fe: Verifying Checksum
7c221cd720fe: Download complete
1b8dfe99e183: Verifying Checksum
1b8dfe99e183: Download complete
39f0ea08a76c: Download complete
3239c63efc84: Verifying Checksum
3239c63efc84: Download complete
391f21a370b4: Download complete
3239c63efc84: Pull complete
772270f4eeb0: Pull complete
1bd9763c7560: Pull complete
f912493fbc67: Pull complete
e67bb4903160: Pull complete
c56f03bb6bc0: Pull complete
e2bcfc885f2b: Verifying Checksum
e2bcfc885f2b: Download complete
d1d7a8c7ae1a: Download complete
f2c32ff93f39: Download complete
f6108b8daef2: Download complete
4f4fb700ef54: Verifying Checksum
4f4fb700ef54: Download complete
908fbf41b45c: Verifying Checksum
908fbf41b45c: Download complete
872e27585d51: Verifying Checksum
872e27585d51: Download complete
b4dcc75110d7: Verifying Checksum
b4dcc75110d7: Download complete
bd37f4e53a35: Verifying Checksum
bd37f4e53a35: Download complete
832c2a8e4491: Verifying Checksum
832c2a8e4491: Download complete
832c2a8e4491: Pull complete
7c221cd720fe: Pull complete
1b8dfe99e183: Pull complete
39f0ea08a76c: Pull complete
391f21a370b4: Pull complete
e2bcfc885f2b: Pull complete
d1d7a8c7ae1a: Pull complete
f6108b8daef2: Pull complete
f2c32ff93f39: Pull complete
4f4fb700ef54: Pull complete
908fbf41b45c: Pull complete
872e27585d51: Pull complete
fb4a0c119ee2: Verifying Checksum
fb4a0c119ee2: Download complete
e39bf648123d: Verifying Checksum
e39bf648123d: Download complete
fb4a0c119ee2: Pull complete
b4dcc75110d7: Pull complete
bd37f4e53a35: Pull complete
a3ee60d1d341: Verifying Checksum
a3ee60d1d341: Download complete
a3ee60d1d341: Pull complete
c811e73378a6: Verifying Checksum
c811e73378a6: Download complete
ecc79205ba48: Verifying Checksum
ecc79205ba48: Download complete
10e63d14836d: Download complete
10e63d14836d: Pull complete
e39bf648123d: Pull complete
636e17929669: Verifying Checksum
636e17929669: Download complete
5444d52fe7f0: Verifying Checksum
1771c20fe4c0: Verifying Checksum
1771c20fe4c0: Download complete
786317a2edc0: Verifying Checksum
786317a2edc0: Download complete
84324f7d8f77: Verifying Checksum
84324f7d8f77: Download complete
33642bd99cc8: Verifying Checksum
33642bd99cc8: Download complete
37533d5ff3c0: Download complete
2c4eb121e2f2: Verifying Checksum
2c4eb121e2f2: Download complete
de5c4f67a60b: Download complete
71aac75e819e: Verifying Checksum
587184fb8579: Verifying Checksum
587184fb8579: Download complete
587184fb8579: Pull complete
c811e73378a6: Pull complete
ecc79205ba48: Pull complete
5444d52fe7f0: Pull complete
636e17929669: Pull complete
1771c20fe4c0: Pull complete
71aac75e819e: Pull complete
786317a2edc0: Pull complete
84324f7d8f77: Pull complete
33642bd99cc8: Pull complete
37533d5ff3c0: Pull complete
2c4eb121e2f2: Pull complete
de5c4f67a60b: Pull complete
Digest: sha256:fac2d30546de9a653896b075155a466d137d04eb8342cc6a7c010d24c843dcdf
Status: Downloaded newer image for dockcross/manylinux_2_28-x64:20230106-1aeaea0
++++ dirname /ITKPythonPackage/scripts/internal/manylinux-build-module-wheels.sh
+++ cd /ITKPythonPackage/scripts/internal
+++ pwd
++ script_dir=/ITKPythonPackage/scripts/internal
++ [[ 0 -eq 0 ]]
++ PYBIN=(/opt/python/*/bin)
++ PYBINARIES=()
++ for version in "${PYBIN[@]}"
++ [[ /opt/python/cp310-cp310/bin == *\c\p\3\7* ]]
++ [[ /opt/python/cp310-cp310/bin == *\c\p\3\8* ]]
++ [[ /opt/python/cp310-cp310/bin == *\c\p\3\9* ]]
++ [[ /opt/python/cp310-cp310/bin == *\c\p\3\1\0* ]]
++ PYBINARIES+=(${version})
++ for version in "${PYBIN[@]}"
++ [[ /opt/python/cp311-cp311/bin == *\c\p\3\7* ]]
++ [[ /opt/python/cp311-cp311/bin == *\c\p\3\8* ]]
++ [[ /opt/python/cp311-cp311/bin == *\c\p\3\9* ]]
++ [[ /opt/python/cp311-cp311/bin == *\c\p\3\1\0* ]]
++ [[ /opt/python/cp311-cp311/bin == *\c\p\3\1\1* ]]
++ PYBINARIES+=(${version})
++ for version in "${PYBIN[@]}"
++ [[ /opt/python/cp36-cp36m/bin == *\c\p\3\7* ]]
++ [[ /opt/python/cp36-cp36m/bin == *\c\p\3\8* ]]
++ [[ /opt/python/cp36-cp36m/bin == *\c\p\3\9* ]]
++ [[ /opt/python/cp36-cp36m/bin == *\c\p\3\1\0* ]]
++ [[ /opt/python/cp36-cp36m/bin == *\c\p\3\1\1* ]]
++ for version in "${PYBIN[@]}"
++ [[ /opt/python/cp37-cp37m/bin == *\c\p\3\7* ]]
++ PYBINARIES+=(${version})
++ for version in "${PYBIN[@]}"
++ [[ /opt/python/cp38-cp38/bin == *\c\p\3\7* ]]
++ [[ /opt/python/cp38-cp38/bin == *\c\p\3\8* ]]
++ PYBINARIES+=(${version})
++ for version in "${PYBIN[@]}"
++ [[ /opt/python/cp39-cp39/bin == *\c\p\3\7* ]]
++ [[ /opt/python/cp39-cp39/bin == *\c\p\3\8* ]]
++ [[ /opt/python/cp39-cp39/bin == *\c\p\3\9* ]]
++ PYBINARIES+=(${version})
++ for version in "${PYBIN[@]}"
++ [[ /opt/python/pp37-pypy37_pp73/bin == *\c\p\3\7* ]]
++ [[ /opt/python/pp37-pypy37_pp73/bin == *\c\p\3\8* ]]
++ [[ /opt/python/pp37-pypy37_pp73/bin == *\c\p\3\9* ]]
++ [[ /opt/python/pp37-pypy37_pp73/bin == *\c\p\3\1\0* ]]
++ [[ /opt/python/pp37-pypy37_pp73/bin == *\c\p\3\1\1* ]]
++ for version in "${PYBIN[@]}"
++ [[ /opt/python/pp38-pypy38_pp73/bin == *\c\p\3\7* ]]
++ [[ /opt/python/pp38-pypy38_pp73/bin == *\c\p\3\8* ]]
++ [[ /opt/python/pp38-pypy38_pp73/bin == *\c\p\3\9* ]]
++ [[ /opt/python/pp38-pypy38_pp73/bin == *\c\p\3\1\0* ]]
++ [[ /opt/python/pp38-pypy38_pp73/bin == *\c\p\3\1\1* ]]
++ for version in "${PYBIN[@]}"
++ [[ /opt/python/pp39-pypy39_pp73/bin == *\c\p\3\7* ]]
++ [[ /opt/python/pp39-pypy39_pp73/bin == *\c\p\3\8* ]]
++ [[ /opt/python/pp39-pypy39_pp73/bin == *\c\p\3\9* ]]
++ [[ /opt/python/pp39-pypy39_pp73/bin == *\c\p\3\1\0* ]]
++ [[ /opt/python/pp39-pypy39_pp73/bin == *\c\p\3\1\1* ]]
++ case $(uname -m) in
+++ uname -m
++ ARCH=x64
++ export PATH=/work/tools/doxygen-1.8.16/bin:/opt/rh/gcc-toolset-11/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/work/tools/doxygen-1.8.16/bin:/opt/rh/gcc-toolset-11/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ case $(uname -m) in
+++ uname -m
++ type doxygen
++ mkdir -p /work/tools
++ pushd /work/tools
++ curl https://data.kitware.com/api/v1/file/62c4d615bddec9d0c46cb705/download -o doxygen-1.8.16.linux.bin.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 7319k  100 7319k    0     0   747k      0  0:00:09  0:00:09 --:--:-- 1089k
++ tar -xvzf doxygen-1.8.16.linux.bin.tar.gz
./doxygen-1.8.16/
./doxygen-1.8.16/bin/
./doxygen-1.8.16/bin/doxygen
++ popd
++ type ninja
++ MANYLINUX_VERSION=_2_28
++ echo 'Building wheels for x64 using manylinux_2_28'
Building wheels for x64 using manylinux_2_28
+ sudo ldconfig
+ export LD_LIBRARY_PATH=/opt/rh/gcc-toolset-11/root/usr/lib64:/opt/rh/gcc-toolset-11/root/usr/lib:/opt/rh/gcc-toolset-11/root/usr/lib64/dyninst:/opt/rh/gcc-toolset-11/root/usr/lib/dyninst:/work/oneTBB-prefix/lib:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64
+ LD_LIBRARY_PATH=/opt/rh/gcc-toolset-11/root/usr/lib64:/opt/rh/gcc-toolset-11/root/usr/lib:/opt/rh/gcc-toolset-11/root/usr/lib64/dyninst:/opt/rh/gcc-toolset-11/root/usr/lib/dyninst:/work/oneTBB-prefix/lib:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64
+ for PYBIN in "${PYBINARIES[@]}"
+ Python3_EXECUTABLE=/opt/python/cp310-cp310/bin/python
++ find -L /opt/python/cp310-cp310/bin/../include/ -name Python.h -exec dirname '{}' ';'
+ Python3_INCLUDE_DIR=/opt/python/cp310-cp310/bin/../include/python3.10
+ echo ''

+ echo Python3_EXECUTABLE:/opt/python/cp310-cp310/bin/python
Python3_EXECUTABLE:/opt/python/cp310-cp310/bin/python
+ echo Python3_INCLUDE_DIR:/opt/python/cp310-cp310/bin/../include/python3.10
Python3_INCLUDE_DIR:/opt/python/cp310-cp310/bin/../include/python3.10
+ [[ -e /work/requirements-dev.txt ]]
+ [[ -e /ITKPythonPackage/requirements-dev.txt ]]
+ /opt/python/cp310-cp310/bin/pip install --upgrade -r /ITKPythonPackage/requirements-dev.txt
Collecting ninja==1.11.1
  Downloading ninja-1.11.1-py2.py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (145 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 146.0/146.0 kB 570.2 kB/s eta 0:00:00
Collecting scikit-build==0.16.2
  Downloading scikit_build-0.16.2-py3-none-any.whl (78 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.1/78.1 kB 3.3 MB/s eta 0:00:00
Requirement already satisfied: packaging in /opt/_internal/cpython-3.10.8/lib/python3.10/site-packages (from scikit-build==0.16.2->-r /ITKPythonPackage/requirements-dev.txt (line 2)) (21.3)
Collecting distro
  Downloading distro-1.8.0-py3-none-any.whl (20 kB)
Requirement already satisfied: setuptools>=42.0.0 in /opt/_internal/cpython-3.10.8/lib/python3.10/site-packages (from scikit-build==0.16.2->-r /ITKPythonPackage/requirements-dev.txt (line 2)) (65.6.0)
Requirement already satisfied: wheel>=0.32.0 in /opt/_internal/cpython-3.10.8/lib/python3.10/site-packages (from scikit-build==0.16.2->-r /ITKPythonPackage/requirements-dev.txt (line 2)) (0.38.4)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /opt/_internal/cpython-3.10.8/lib/python3.10/site-packages (from packaging->scikit-build==0.16.2->-r /ITKPythonPackage/requirements-dev.txt (line 2)) (3.0.9)
Installing collected packages: ninja, distro, scikit-build
  Attempting uninstall: scikit-build
    Found existing installation: scikit-build 0.8.1
    Uninstalling scikit-build-0.8.1:
      Successfully uninstalled scikit-build-0.8.1
Successfully installed distro-1.8.0 ninja-1.11.1 scikit-build-0.16.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip available: 22.3.1 -> 23.1.2
[notice] To update, run: /opt/_internal/cpython-3.10.8/bin/python -m pip install --upgrade pip
+++ dirname /opt/python/cp310-cp310/bin
++ basename /opt/python/cp310-cp310
+ version=cp310-cp310
+ version=cp310-cp3
++ basename '/ITKPythonPackage/ITK-cp310-cp3*-manylinux_2_28_x64'
+ itk_build_dir='/work/ITK-cp310-cp3*-manylinux_2_28_x64'
+ ln -fs '/ITKPythonPackage/ITK-cp310-cp3*-manylinux_2_28_x64' '/work/ITK-cp310-cp3*-manylinux_2_28_x64'
+ [[ ! -d /work/ITK-cp310-cp3*-manylinux_2_28_x64 ]]
+ echo 'ITK build tree not available!'
ITK build tree not available!
+ exit 1
Cleaning up artifacts from module build
unlink: cannot unlink 'oneTBB-prefix': No such file or directory

How can fix this problem?

This error sounds familiar. @Tom_Birdsong do you remember the solution?

Hi @nnzzll , welcome to the ITK forums!

It looks like the ITKPythonPackage documentation needs to be updated, thanks for bringing this to our attention. We have introduced several new features and fixes to the project since the ITK v5.3.0 release. In this case there appears to be a tag mismatch where dockcross-manylinux-download-cache-and-build-module-wheels.sh attempts to fetch a script that did not exist until post-v5.3.0.

To move forward with your build you can add an export step to set the ITKPythonPackage remote tag to use to the latest version (dc6a1860):

export ITKPYTHONPACKAGE_TAG=dc6a18600233ac69a8f42b7489e4edf6a5d8883a
./ITKPythonPackage/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh
1 Like