Skip to content

BUG: Fix problems found while reviewing and testing PR #312 - #315

Open
dzenanz wants to merge 23 commits into
InsightSoftwareConsortium:mainfrom
dzenanz:pr312-review-fixes
Open

dzenanz wants to merge 23 commits into
InsightSoftwareConsortium:mainfrom
dzenanz:pr312-review-fixes

Conversation

@dzenanz

@dzenanz dzenanz commented Nov 24, 2026

Copy link
Copy Markdown
Member

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

  • Linux: stop when the cache download fails, instead of failing later with exit 127.
  • Linux: reject MANYLINUX_VERSION other than _2_28, which is the only one with caches.
  • Linux: pass -x/--exclude_libs to auditwheel as --exclude.
  • Linux: pass LD_LIBRARY_PATH into the container.
  • Windows: repair module wheels with the --lib-paths directories and oneTBB's bin, as itk-core is.
  • Windows: strip the quotes the CI action puts around each CMake option.
  • macOS: reject unknown options, and fail at the first failed build instead of exiting 0.

Step report and rebuild inputs

  • Each module build writes its own step report instead of replacing the ITK build's.
  • Uncommitted changes and untracked files in the ITK source change itk_commit.
  • Untracked files in a module change module_state.
  • The wheel repair options and --module-itk-dir enter the fingerprint.

Other build fixes

  • --cleanup keeps dist/ when the build root is inside the checkout.
  • The ITK version lookup stays inside the ITK tree, and works offline from local tags.
  • Rebuilding ITK without the compiler cache clears a launcher left in the reused build tree. Module builds keep it, so they don't rebuild oneTBB.
  • --platform-env defaults to the active manylinux pixi environment, so the environment guard no longer aborts there.
  • Windows: backslashes in CMAKE_OPTIONS are kept.
  • Windows: the cache archive is created anew instead of being updated in place.

Tests on Windows

  • Shell script tests run Git's bash, not WSL's System32\bash.exe.
  • Path and cgroup tests compare paths as Windows writes them.
  • The zip fallback test ignores an installed 7-Zip.
Found in the review but left as is
  • The default Python matrix of ITKRemoteModuleBuildTestPackageAction: it lives in that repository.
  • Publishing the caches to ITKPythonBuilds: an operational step, not code.
  • The pixi deprecation warnings: the new manifest syntax affects the lock file and older pixi.
Test results

Type of Change

  • Bug fix
  • New feature / enhancement
  • Refactor / cleanup
  • Docs / CI only

Checklist

  • Pre-commit hooks pass locally (pre-commit run --all-files), except prettier
  • Tested wheel build on affected platform(s) (Linux / macOS / Windows)
  • Docs updated if behavior changed (docs/)
  • Commit messages use ITK prefixes (BUG:, COMP:, DOC:, ENH:, PERF:, STYLE:)

Platform(s) Tested

  • Linux x86_64 (manylinux)
  • Linux aarch64 (manylinux)
  • macOS arm64
  • Windows x86_64 (test suite only)

Related Issues

Follow-up to #312.

AI assistance

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.
@dzenanz
dzenanz requested a review from hjmjohnson November 24, 2026 19:36
@dzenanz dzenanz changed the title BUG: Stop the Linux module build when the cache download fails BUG: Fix problems found while reviewing and testing PR #312 Nov 24, 2026
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
dzenanz marked this pull request as ready for review November 24, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant