Skip to content

BUG: Fix bugs and edge cases found reviewing #315 - #320

Open
hjmjohnson wants to merge 8 commits into
InsightSoftwareConsortium:mainfrom
BRAINSia:followup-bugs
Open

hjmjohnson wants to merge 8 commits into
InsightSoftwareConsortium:mainfrom
BRAINSia:followup-bugs

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Fix the bugs and missed edge cases found while reviewing #315, one commit each, and add tests for three #315 fixes that had none. The biggest one: an untracked CMake build tree inside the ITK source (an IDE's cmake-build-*/) was hashed into itk_commit on every run, so ITK rebuilt every time.
Merge danger: two-way door; blast radius: Linux, macOS, and Windows module builds through the CI action, and local rebuild decisions.

Shape of the change
Commit Problem Fix
LD_LIBRARY_PATH Linux module script built /a:/b:/a:; the trailing : means the current directory join with : between entries only
repeated -x nargs=1 kept only the last --exclude-libs / --lib-paths action="append", joined with ;
ITK source state build trees hashed; nested repo raised IsADirectoryError and the except dropped every other change; non-UTF-8 names raised skip dirs holding CMakeCache.txt; nested repo counts by HEAD + changes; symlink by target; unreadable file by name; names read as bytes
--platform-env default any active env with a - (e.g. dev-docs) passed the guard is_platform_env: <linux|manylinuxNNN|macosx|windows>-pyNNN, used in both places
Windows CMAKE_OPTIONS doubling backslashes broke '-DX=C:\a' shlex lexer with no escape character on Windows
-D options the CI action passes --cmake_options -DA=1 -DB=2 unquoted; both shell scripts stopped at -DB=2 each further -D argument joins CMAKE_OPTIONS; macOS also stops looping on a trailing --cmake_options
PowerShell options split on every space, so "-DX=C:\a b" broke; -setup_options kept quotes; spaces alone gave a bare -- Split-Options splits on unquoted whitespace and drops quotes
tests #315's manylinux guard, failed-download stop, and --module-itk-dir fingerprint had no test three tests
Evidence
  • Each new or changed test was run against the code before its fix and failed, then passed after it (the macOS trailing-option test hit its 60 s timeout before the fix).
  • pixi run -e dev python -m pytest tests -q: 526 passed, 8 skipped (macOS; the skips are the PowerShell test and a Linux-only non-UTF-8 file name test).
  • The PowerShell test passes with Windows PowerShell 5.1 on a Windows builder (7 passed; 7 failed with the old script).
  • pre-commit run --all-files: passed.
  • All three follow-up PRs merged together: 535 passed, pre-commit passed.
  • Not run: a module wheel build through the CI action on any platform.
Not changed

@hjmjohnson
hjmjohnson marked this pull request as ready for review November 26, 2026 02:59

@dzenanz dzenanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixes look right. The -D* cases match how the action really calls the Linux and macOS scripts, with $CMAKE_OPTIONS unquoted so it word-splits.

With #318, #319 and #320 merged on main, the tests on Windows give 534 passed, 2 failed and 7 skipped. Both failures are new tests from this PR (see inline).

Comment thread tests/test_build_inputs.py Resolved
Comment thread tests/test_module_script_arguments.py Resolved
@dzenanz

dzenanz commented Nov 26, 2026

Copy link
Copy Markdown
Member

Manual glance at the changes did not spot any problems.

Each mounted directory was added as "<new>:<everything so far>" onto
everything so far, so two directories gave /a:/b:/a: and the value
always ended in ":". An empty entry in LD_LIBRARY_PATH means the
current directory, so auditwheel searched wherever it was run from.

Join the container paths with ":" between them only, and start from an
empty value rather than one inherited from the environment.
The Linux module script turns each -x into its own --exclude-libs, and
argparse's nargs=1 kept only the last of them, so all but one library
were bundled without a word. --lib-paths had the same shape.

Append each occurrence and join them with ";" into the one-element list
the builders already take.
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.
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.
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.
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.
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.
- 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 hjmjohnson left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two force-pushes: the first (fea553f..2003325) is a plain rebase on main after #318 and #319 merged, with every commit unchanged; the second (2003325..e6b3661) holds only these three review fixes. I could not run the two tests on Windows here; could you rerun them on your Windows box?

Comment thread tests/test_build_inputs.py Resolved
Comment thread tests/test_module_script_arguments.py Resolved
@hjmjohnson
hjmjohnson requested a review from dzenanz November 26, 2026 20:35
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.

2 participants