Repository navigation
BUG: Fix problems found while reviewing and testing PR #312 - #315
Merged
hjmjohnson merged 23 commits intoNov 26, 2026
Merged
Conversation
The Linux module script ignored the exit status of the cache download: when the ITKPythonBuilds tarball was missing, dockcross-manylinux- download-cache.sh exited 1, and the script went on to run ITKPythonPackage/scripts/dockcross-manylinux-build-module-wheels.sh, which the missing tarball should have provided. The job then failed with exit 127, "No such file or directory", instead of the download error. Fetching the download script with plain curl -L likewise kept an HTTP error page as the script. Exit when either the download script cannot be fetched (curl -f) or it fails.
…uild Workflows that still list 2014-x64 in manylinux-platforms, such as ITKANTsWasm and ITKGenericLabelInterpolator, ran the Linux module script with MANYLINUX_VERSION=2014. It tried to download ITKPythonBuilds-manylinux2014-x64.tar.zst, which is no longer built, and then a container image and a pixi environment that do not exist. Say that only manylinux_2_28 is built, before downloading anything.
fixup_module_wheel called fixup_wheel without library paths, so a remote module's wheel was repaired with delvewheel --add-path "": the --lib-paths directories given to build_wheels.py (for instance -setup_options "--lib-paths C:\CUDA\bin", as windows-download-cache-and-build-module-wheels.ps1 documents) and oneTBB-prefix\bin were searched only for itk-core. A module that needs a DLL from one of them failed to repair, or bundled whatever copy was on PATH. The previous windows_build_module_wheels.py added both. Search the same directories for module wheels as for itk-core.
ITKRemoteModuleBuildTestPackageAction puts each Windows CMake option in double quotes and passes them as one string: -cmake_options '"-DA:BOOL=ON" "-DB=2"' The previous script ran its command line through Invoke-Expression, which removed those quotes. The new one splits the string on spaces and passes the pieces to pixi, so build_wheels.py received "-DA:BOOL=ON" with its quotes, did not take it for a -D definition, and stopped with "CMake option '\"-DA:BOOL=ON\"' is not a -D<KEY>=<VALUE> definition". Drop the quotes from each option, and skip empty pieces from repeated spaces. Checked with PowerShell 7.6 and Windows PowerShell 5.1.
ITKRemoteModuleBuildTestPackageAction runs ./macpython-download-cache-and-build-module-wheels.sh $CMAKE_OPTIONS 3.11 with CMAKE_OPTIONS="--cmake_options -DA=1 -DB=2" unquoted. The script took -DA=1 as the CMake options and -DB=2 as a Python version, built the module without -DB=2, failed to find a "macosx-py-DB=2" pixi environment, and still exited 0, because only the last build's status counted. Reject an unknown option, as the Linux module script does, and stop at the first build that fails.
The Linux module script accepted -x/--exclude_libs only to print that it was ignored, and build_wheels.py applied --exclude-libs on Windows alone. A module that links the CUDA driver or runtime, such as RTK with RTK_USE_CUDA, therefore had libcuda.so.1 and the other CUDA libraries grafted into its manylinux wheel by auditwheel, as the previous scripts prevented with auditwheel --exclude. Pass -x on to build_wheels.py as --exclude-libs, and give auditwheel an --exclude for each library it names.
dockcross-manylinux-build-module-wheels.sh mounts each LD_LIBRARY_PATH directory at /usr/lib64/<name> and sets LD_LIBRARY_PATH to those mount points, but no longer passes the variable into the container; the previous script added -e LD_LIBRARY_PATH to the docker arguments. auditwheel in the container therefore did not look in the mounted directories, and a module whose libraries come from there failed to repair. Pass the rewritten LD_LIBRARY_PATH to the container when it is set.
On Windows, subprocess.run(["bash", ...]) starts C:\Windows\System32\bash.exe, the WSL launcher, even when Git's bash comes first on PATH, because process creation searches System32 before PATH. Without a WSL distribution it fails, so 14 tests of the module scripts and require_env_vars.sh failed on Windows. Take bash from Git for Windows there, next to git, and skip the tests when there is none.
On Windows str(Path("/bdr/ITK")) is "\bdr\ITK", so four BuildConfig
environment tests, which expected "/bdr/ITK", failed there, and the
fake cgroup files of test_cgroup_v2_limit_caps_reported_memory, looked
up by str(path), were never found.
Expect the paths as the host renders them, and look the fake cgroup
files up by their POSIX form.
In a raw string "\\" is two backslashes, so r"C:\Program Files\7-Zip" named a path with doubled separators. pathlib collapses them, which is why 7-Zip was still found; write the paths as they are.
test_zip_fallback_archives_the_seven_zip_roots hid 7-Zip by patching shutil.which, but build_tarball checks C:\Program Files\7-Zip\7z.exe and two other fixed paths first. On a Windows host with 7-Zip installed, the test ran 7-Zip and failed. Name the fixed paths in a module constant, which the test empties.
build_tarball ran "7z a" on ITKPythonBuilds-windows.zip, which updates an existing archive: files deleted from the build tree since the last --build-itk-tarball-cache run stayed in the cache, and a module build extracting it got them back. Only the zip fallback removed the old archive first. Remove it before running 7-Zip too.
A remote module build wrote its steps to the same dist/build_log_<platform-env>.json as the ITK build. Its inputs carry a module state the ITK build's lack, so each run found the inputs changed and replaced the ITK build's records with its own skipped steps: the next ITK build reran every step, and dependency modules, built into the same report, did the same to each other. Name a module build's report build_log_<platform-env>_<module>.json.
The step report recorded the ITK commit, HEAD, as the build's ITK input. Editing ITK sources, or adding a file, without committing left it unchanged, so a rerun skipped the ITK build and wheel steps and packaged the previous build: the local edits never reached the wheels. Record "<commit>+<hash>" when the ITK tree has changes to tracked files or untracked files git does not ignore, as the module state already does for changes to a module's tracked files.
module_source_state hashed "git diff HEAD", which leaves out untracked files. Adding a new header, source, or .wrap file to a module without committing it left the state unchanged, so a rerun skipped the module wheel step and kept the wheel built without it. Hash the untracked files git does not ignore too, except the build outputs and caches MODULE_STATE_SKIP already leaves out of a module without a repository.
The build inputs left out --lib-paths, --exclude-libs, and, for a remote module, --module-itk-dir. Rerunning with a different value found every step done and kept wheels repaired with the old library paths and exclusions, or a module built against the other ITK tree. Add them to the settings the fingerprint covers.
post_build_cleanup removes the checkout's build/ directory. With --build-dir-root <ipp>/build, that is the build root itself, so --cleanup deleted dist/ and the wheels just built. Leave a directory that holds the build root in place.
sync_itk_source runs git with GIT_CEILING_DIRECTORIES set to the ITK tree's parent, so a tree restored from a cache, whose .git is empty, is used as it is. compute_itk_package_version then ran git with the plain environment: inside another checkout, such as a module or ITKPythonPackage clone, git found that repository, fetched its tags, checked out the ITK tag there, and named the wheels after its "git describe" if that worked. Give the version derivation the same environment, so such a tree gets the error that asks for --itk-package-version.
sync_itk_source lets a build go on without network access when the requested ITK revision is already present, but compute_itk_package_version then ran "git fetch --tags" again and stopped the build when it failed. An offline build with the default --itk-package-version gitauto could therefore never start. Warn and describe the revision with the local tags instead.
--use-compiler-cache sets CMAKE_C_COMPILER_LAUNCHER and CMAKE_CXX_COMPILER_LAUNCHER, and CMake keeps them in the build tree's cache. Rebuilding that tree with --no-use-compiler-cache set nothing, so the compiles still went through ccache or sccache. When the ITK build runs without the cache, set both launchers to empty and ITK_USE_CCACHE to OFF. A module build on a cached tree, which skips the ITK build, leaves them as they are: clearing them would only make the superbuild rebuild oneTBB, which gets the launcher too.
Without --platform-env, build_wheels.py used get_default_platform_build(), which spells the manylinux228-py311 environment manylinux_2_28-py311, the form the tarball names need. The environment guard then compared that with PIXI_ENVIRONMENT_NAME and aborted the build with "WRONG ENVIRONMENT" inside the very environment it asks for. Default to the active environment's own name when one is active.
The CMAKE_OPTIONS environment variable is split with shlex, which takes a backslash outside quotes for an escape character, so on Windows CMAKE_OPTIONS="-DFOO_DIR=C:\deps\foo" reached CMake as -DFOO_DIR=C:depsfoo. On Windows, double each backslash before splitting, so that the split keeps it.
ITK loads itk/__init_<module>__.py using the module name from itk/Configuration/<Module>Config.py, which need not match the distribution name: itk-vkfft wraps VkFFTBackend. Deriving the name from the distribution gave __init_vkfft__.py, so ITK never ran the DLL search setup delvewheel adds on Windows. Take the name from the wheel's Configuration member, keeping the distribution name as a fallback.
dzenanz
marked this pull request as ready for review
November 24, 2026 22:20
hjmjohnson
approved these changes
Nov 26, 2026
hjmjohnson
left a comment
Member
There was a problem hiding this comment.
A new nits and refinements suggestions will be in a folloup.
This was referenced Nov 26, 2026
dzenanz
pushed a commit
that referenced
this pull request
Nov 26, 2026
#315 made --exclude-libs (-x in the Linux module script) pass each library to auditwheel as --exclude, but AGENTS.md and README.md still called it Windows only, and the module guide did not show -x. AGENTS.md and the ITK build guide also listed _2_34 as a manylinux version. Only manylinux_2_28 has a pixi environment and ITK caches, and the Linux module script now rejects anything else. The Windows example in the module guide used Python 3.10 and showed --exclude-libs where the text described --lib-paths; it now shows both with Python 3.11.
dzenanz
added a commit
that referenced
this pull request
Nov 26, 2026
DOC: Bring the docs in line with #315 (--exclude-libs on Linux, manylinux_2_28 only)
hjmjohnson
added a commit
that referenced
this pull request
Nov 26, 2026
STYLE: Clean up code smells found reviewing #315
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 26, 2026
InsightSoftwareConsortium#315 hashed every untracked file in the ITK source into itk_commit, so a build could not reuse one made from different sources. Three cases broke it: - A CMake build tree inside the source, such as an IDE's cmake-build-release/, is untracked unless a .gitignore covers it. It was hashed in full on every run, and since each build rewrites it, ITK rebuilt every time. A directory holding CMakeCache.txt is now skipped. - git lists an untracked nested repository as one "<name>/" entry. Opening it raised IsADirectoryError, which resolved_itk_commit caught and answered with the bare commit, dropping every other change. It now counts by its own HEAD and uncommitted changes. - A dangling symlink or an unreadable file failed the same way; the symlink now counts by its target, the unreadable file by its name. File names are read as bytes, so a name that is not UTF-8 no longer raises UnicodeDecodeError.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 26, 2026
InsightSoftwareConsortium#315 took the active pixi environment as the --platform-env default whenever its name held a hyphen, and get_default_platform_build used the same test. An unrelated environment with a hyphen, such as dev-docs, passed the environment guard and failed later as an unknown platform. is_platform_env matches the names that build wheels, <linux|manylinuxNNN|macosx|windows>-pyNNN, and both places use it.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 26, 2026
InsightSoftwareConsortium#315 kept the backslashes of Windows paths by doubling every one before shlex.split. Inside single quotes shlex does not unescape, so '-DX=C:\a' arrived as -DX=C:\\a. On Windows, split with a shlex lexer that has no escape character, so backslashes are literal everywhere and quotes still group. Other platforms keep shlex.split's shell rules.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 26, 2026
ITKRemoteModuleBuildTestPackageAction passes its cmake-options input as --cmake_options -DA=1 -DB=2 without quotes. --cmake_options took -DA=1, and both scripts then stopped at -DB=2 as an unexpected option (the macOS one since InsightSoftwareConsortium#315; before, it took -DB=2 for a Python version). Each further -D argument is now added to CMAKE_OPTIONS, so the action works with several options without a change there. The macOS script also looped forever on a trailing --cmake_options with no value, as shift 2 fails without shifting when one argument is left. It now shows usage, as the Linux script does.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 26, 2026
InsightSoftwareConsortium#315 split -cmake_options on every space and trimmed quotes from each piece, so "-DX=C:\a b" became two arguments. -setup_options was split the same way without the trimming, so a quoted --lib-paths directory kept its quotes. An -cmake_options of spaces alone added a bare "--". Split-Options splits both on whitespace outside quotes and removes the quotes, keeping backslashes literal. The new test runs it with PowerShell where one is installed; it passes with Windows PowerShell 5.1 on a Windows builder.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 26, 2026
- The Linux module script stops before downloading when MANYLINUX_VERSION has no ITK caches. - It stops when the cache script cannot be downloaded, instead of running a missing script. - --module-itk-dir enters the build fingerprint. The script tests now run in a temporary directory, so a script that downloads does not write into the checkout.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 26, 2026
InsightSoftwareConsortium#315 hashed every untracked file in the ITK source into itk_commit, so a build could not reuse one made from different sources. Three cases broke it: - A CMake build tree inside the source, such as an IDE's cmake-build-release/, is untracked unless a .gitignore covers it. It was hashed in full on every run, and since each build rewrites it, ITK rebuilt every time. A directory holding CMakeCache.txt is now skipped. - git lists an untracked nested repository as one "<name>/" entry. Opening it raised IsADirectoryError, which resolved_itk_commit caught and answered with the bare commit, dropping every other change. It now counts by its own HEAD and uncommitted changes. - A dangling symlink or an unreadable file failed the same way; the symlink now counts by its target, the unreadable file by its name. File names are read as bytes, so a name that is not UTF-8 no longer raises UnicodeDecodeError.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 26, 2026
InsightSoftwareConsortium#315 took the active pixi environment as the --platform-env default whenever its name held a hyphen, and get_default_platform_build used the same test. An unrelated environment with a hyphen, such as dev-docs, passed the environment guard and failed later as an unknown platform. is_platform_env matches the names that build wheels, <linux|manylinuxNNN|macosx|windows>-pyNNN, and both places use it.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 26, 2026
InsightSoftwareConsortium#315 kept the backslashes of Windows paths by doubling every one before shlex.split. Inside single quotes shlex does not unescape, so '-DX=C:\a' arrived as -DX=C:\\a. On Windows, split with a shlex lexer that has no escape character, so backslashes are literal everywhere and quotes still group. Other platforms keep shlex.split's shell rules.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 26, 2026
ITKRemoteModuleBuildTestPackageAction passes its cmake-options input as --cmake_options -DA=1 -DB=2 without quotes. --cmake_options took -DA=1, and both scripts then stopped at -DB=2 as an unexpected option (the macOS one since InsightSoftwareConsortium#315; before, it took -DB=2 for a Python version). Each further -D argument is now added to CMAKE_OPTIONS, so the action works with several options without a change there. The macOS script also looped forever on a trailing --cmake_options with no value, as shift 2 fails without shifting when one argument is left. It now shows usage, as the Linux script does.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 26, 2026
InsightSoftwareConsortium#315 split -cmake_options on every space and trimmed quotes from each piece, so "-DX=C:\a b" became two arguments. -setup_options was split the same way without the trimming, so a quoted --lib-paths directory kept its quotes. An -cmake_options of spaces alone added a bare "--". Split-Options splits both on whitespace outside quotes and removes the quotes, keeping backslashes literal. The new test runs it with PowerShell where one is installed; it passes with Windows PowerShell 5.1 on a Windows builder.
hjmjohnson
added a commit
to BRAINSia/ITKPythonPackage
that referenced
this pull request
Nov 26, 2026
- The Linux module script stops before downloading when MANYLINUX_VERSION has no ITK caches. - It stops when the cache script cannot be downloaded, instead of running a missing script. - --module-itk-dir enters the build fingerprint. The script tests now run in a temporary directory, so a script that downloads does not write into the checkout.
dzenanz
added a commit
that referenced
this pull request
Nov 27, 2026
BUG: Fix bugs and edge cases found reviewing #315
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes 22 problems found while reviewing and testing #312. Each commit fixes one problem, and its message explains it.
Changes by area
Remote module scripts
MANYLINUX_VERSIONother than_2_28, which is the only one with caches.-x/--exclude_libsto auditwheel as--exclude.LD_LIBRARY_PATHinto the container.--lib-pathsdirectories and oneTBB'sbin, asitk-coreis.Step report and rebuild inputs
itk_commit.module_state.--module-itk-direnter the fingerprint.Other build fixes
--cleanupkeepsdist/when the build root is inside the checkout.--platform-envdefaults to the active manylinux pixi environment, so the environment guard no longer aborts there.CMAKE_OPTIONSare kept.Tests on Windows
System32\bash.exe.Found in the review but left as is
Test results
pixi run teston Windows: 496 passed, 6 skipped. At ENH: Replace the shell wheel build system with Python (supersedes #309) #312's head, 20 tests failed on Windows.pre-commit run --all-filespasses, except prettier, which was skipped because its node environment does not install on this host.Type of Change
Checklist
pre-commit run --all-files), except prettierdocs/)BUG:,COMP:,DOC:,ENH:,PERF:,STYLE:)Platform(s) Tested
Related Issues
Follow-up to #312.
AI assistance