Skip to content

Add installation support for windows#82

Merged
blowekamp merged 1 commit intoSimpleITK:mainfrom
Artur-man:addWindowsSupport
Apr 8, 2026
Merged

Add installation support for windows#82
blowekamp merged 1 commit intoSimpleITK:mainfrom
Artur-man:addWindowsSupport

Conversation

@Artur-man
Copy link
Copy Markdown
Collaborator

@Artur-man Artur-man commented Mar 19, 2026

This PR is based on discussions across #72 #78 #80 and meetings with @richardbeare @blowekamp @zivy.

fixes #72

Description

  • added configure.win required for Windows installation.
  • updated GHA to test windows build.
  • added instructions to README.md.

Notes

Copy link
Copy Markdown
Member

@zivy zivy left a comment

Choose a reason for hiding this comment

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

The windows runner does not seem to be identified correctly (if: startsWith(matrix.config.os, 'windows')), so the actual configuration and building were not run. Successful and fast run on the dashboard, but this isn't a real success. The CircleCI was successful and fast too, so I checked that too and it was indeed run and built.

@Artur-man was this executing for you under your repository?

@blowekamp blowekamp requested a review from Copilot March 20, 2026 13:33
@Artur-man
Copy link
Copy Markdown
Collaborator Author

@zivy thanks for catching this, looking at it now.

@blowekamp
Copy link
Copy Markdown
Member

Is this dependent on a fixed FindR.cmake file? When is that change needed?

@Artur-man
Copy link
Copy Markdown
Collaborator Author

@blowekamp yes, will send over that PR too soon.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Artur-man
Copy link
Copy Markdown
Collaborator Author

Artur-man commented Mar 20, 2026

@blowekamp I think we also need to update the ITK_TAG to the version where problem with GDCM was fixed. I have not touched it here since we only introduce the windows builders, we can leave the PR as it is until we release the fixes to upstream ? or ... ?

@blowekamp
Copy link
Copy Markdown
Member

It looks like I only back ported the change to ITK release-5.4 branch but never update SImpleITK's release (2.x) branch.

or ... ?

We could just work on the the 3.0.0a03 tag instead of back porting things. Your call based on your needs.

@Artur-man
Copy link
Copy Markdown
Collaborator Author

Artur-man commented Mar 27, 2026

ok, win builds in R=4.4.1 with new SimpleITK release and default ITK_TAG ... but gives a strange error in 4.3 (too big file size?)
https://github.com/Artur-man/SimpleITKRInstaller/actions/runs/23648836524/job/68905985618

Will push this here too. Should I use v3.0.0a3 tag now ... one problem is that, this fails in Rcheck since R version cannot have letters ... so it has to be 3.0.0 or smthn

@blowekamp
Copy link
Copy Markdown
Member

ok, win builds in R=4.4.1 with new SimpleITK release and default ITK_TAG ... but gives a strange error in 4.3 (too big file size?) https://github.com/Artur-man/SimpleITKRInstaller/actions/runs/23648836524/job/68905985618

Will push this here too. Should I use v3.0.0a3 tag now ... one problem is that, this fails in Rcheck since R version cannot have letters ... so it has to be 3.0.0 or smthn

Use the hash of SimpleITK release: 1899b2

@blowekamp
Copy link
Copy Markdown
Member

@Artur-man We have the fixed in SimpleITK upstream with the needed fixes for compilation and cmake configuration. What are the next steps to move this forward? Any additional help needed?

@Artur-man
Copy link
Copy Markdown
Collaborator Author

Artur-man commented Apr 6, 2026

Thanks for checking in @blowekamp. I was preparing for a hackathon so ignored this PR for a while.

I think I can start testing again after runs in another branch
https://github.com/Artur-man/SimpleITKRInstaller/tree/addwin_temp

Currently, my main issue is with the version of the SimpleITK. Currently we parse that from the version field of the DESCRIPTION file in the R package bundle. But in order for build to be successful it should be a proper version number (e.g. 2.5.3 or 3.0.0), but say 3.0.0a3, 1899b2 or release is not acceptable.
https://github.com/Artur-man/SimpleITKRInstaller/blob/addwin_temp/configure.win

Is there a tag/version like that we can use now ? or should I pull from 3.0.0a3 or 1899b2 ? (again you cannot put them in DESCRIPTION)

Which works fine in R 4.4.1 but 4.3 is failing for some reason
https://github.com/Artur-man/SimpleITKRInstaller/actions/runs/23648836524

@Artur-man
Copy link
Copy Markdown
Collaborator Author

@blowekamp seems my pushes are not triggering actions.

@blowekamp
Copy link
Copy Markdown
Member

I am not sure. There are some restrictions based on user, but I though I configured those so it would work for you.

Please make a separate PR with just the trivial .gitignore changes. Perhaps having a commit in the repo will help.

@Artur-man
Copy link
Copy Markdown
Collaborator Author

Hmm, seems I am not allowed to commit either. I thought I accepted the offer to contribute but perhaps it did not work ?

@blowekamp
Copy link
Copy Markdown
Member

Hmm, seems I am not allowed to commit either. I thought I accepted the offer to contribute but perhaps it did not work ?

I am not sure what you mean that you are not allow to commit. Please make a new branch locally, then add and commit the .gitignore change. Next push to your fork, and make a PR to this repo.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 31 to +57
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.R }}
- name: System Dependencies
if: startsWith( matrix.os, 'ubuntu' )
run: |
sudo apt-get -y update &&
sudo apt-get install -y libcurl4-openssl-dev libssh2-1-dev libharfbuzz-dev libfribidi-dev gh &&
sudo rm -rf /var/lib/apt/lists/*
- name: Configuration Information
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
mkdir ${R_LIBS}
c++ --version
cmake --version
which R
R --version
- name: Configuration Information (Windows)
if: startsWith(matrix.os, 'windows')
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path "$env:R_LIBS" | Out-Null
g++ --version
cmake --version
Get-Command R.exe
R.exe --version
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

The Windows job doesn't install Rtools (or otherwise ensure a working MinGW toolchain is on PATH). Since configure.win requires Rtools and the workflow runs g++ --version and builds C++ code, add an explicit Rtools setup step (e.g., r-lib/actions/setup-rtools) and/or set RTOOLS_HOME so the build is reproducible on GitHub-hosted runners.

Copilot uses AI. Check for mistakes.
Comment on lines +66 to +67
Rscript -e "lib <- Sys.getenv('R_LIBS'); lib <- normalizePath(lib, winslash='/', mustWork=FALSE); dir.create(lib, recursive=TRUE, showWarnings=FALSE); install.packages('remotes', lib=lib, repos='https://cloud.r-project.org/')"
Rscript.exe -e "install.packages(c('remotes', 'desc'), repos='https://cloud.r-project.org/')"
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

The Windows package-install step installs remotes twice and installs desc without targeting the same library path as $env:R_LIBS. This can lead to packages landing in a non-writable default library or not being visible via .libPaths() during the build. Install both remotes and desc once, explicitly into $env:R_LIBS (after normalizing/creating it).

Suggested change
Rscript -e "lib <- Sys.getenv('R_LIBS'); lib <- normalizePath(lib, winslash='/', mustWork=FALSE); dir.create(lib, recursive=TRUE, showWarnings=FALSE); install.packages('remotes', lib=lib, repos='https://cloud.r-project.org/')"
Rscript.exe -e "install.packages(c('remotes', 'desc'), repos='https://cloud.r-project.org/')"
Rscript.exe -e "lib <- Sys.getenv('R_LIBS'); lib <- normalizePath(lib, winslash='/', mustWork=FALSE); dir.create(lib, recursive=TRUE, showWarnings=FALSE); install.packages(c('remotes', 'desc'), lib=lib, repos='https://cloud.r-project.org/')"

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +28
export RTOOLS_HOME="$(ls -d /c/rtools* | head -n 1)"
if [ -z "$RTOOLS_HOME" ]; then
echo "Environment variable \"RTOOLS_HOME\" is not set!" 1>&2
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

The script overwrites RTOOLS_HOME by auto-detecting /c/rtools* but then errors with "RTOOLS_HOME is not set". This is contradictory to the README instructions and prevents users from pinning a specific Rtools install. Only auto-detect when RTOOLS_HOME is empty, and improve the error message to reflect what was checked.

Suggested change
export RTOOLS_HOME="$(ls -d /c/rtools* | head -n 1)"
if [ -z "$RTOOLS_HOME" ]; then
echo "Environment variable \"RTOOLS_HOME\" is not set!" 1>&2
if [ -z "$RTOOLS_HOME" ]; then
for rtools_dir in /c/rtools*; do
if [ -d "$rtools_dir" ]; then
export RTOOLS_HOME="$rtools_dir"
break
fi
done
fi
if [ -z "$RTOOLS_HOME" ]; then
echo "Environment variable \"RTOOLS_HOME\" is not set, and no Rtools installation was found under /c/rtools*." 1>&2

Copilot uses AI. Check for mistakes.
fi

# Update PATH to include Rtools binaries
export PATH="${RTOOLS_HOME}/usr/bin:${RTOOLS_HOME}/x86_64-w64-mingw32.static.posix/bin:${PATH}"
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

The PATH entry ${RTOOLS_HOME}/x86_64-w64-mingw32.static.posix/bin does not match the Rtools 4.5 layout suggested in the README (e.g., C:/rtools45 uses ucrt64/bin). As written, this will fail to find the compiler on current Rtools installations. Update the PATH logic to handle the current Rtools directory structure (or detect the correct subdir).

Suggested change
export PATH="${RTOOLS_HOME}/usr/bin:${RTOOLS_HOME}/x86_64-w64-mingw32.static.posix/bin:${PATH}"
if [ -d "${RTOOLS_HOME}/ucrt64/bin" ]; then
RTOOLS_BIN="${RTOOLS_HOME}/ucrt64/bin"
elif [ -d "${RTOOLS_HOME}/x86_64-w64-mingw32.static.posix/bin" ]; then
RTOOLS_BIN="${RTOOLS_HOME}/x86_64-w64-mingw32.static.posix/bin"
elif [ -d "${RTOOLS_HOME}/mingw64/bin" ]; then
RTOOLS_BIN="${RTOOLS_HOME}/mingw64/bin"
else
echo "Could not find an Rtools compiler bin directory under ${RTOOLS_HOME}" 1>&2
exit 1
fi
export PATH="${RTOOLS_HOME}/usr/bin:${RTOOLS_BIN}:${PATH}"

Copilot uses AI. Check for mistakes.
@Artur-man
Copy link
Copy Markdown
Collaborator Author

not sure why the "file size is big" error in 4.3 but not in 4.4 ...

@blowekamp
Copy link
Copy Markdown
Member

In SimpleITK 3.0 this filter compilation of type was reduced with this change: SimpleITK/SimpleITK#2272 So hopefully this issue won't be there with shortly. Perhaps it's best to just drop this R version on windows for now?

@Artur-man
Copy link
Copy Markdown
Collaborator Author

Yes I can remove 4.3 from windows build, but perhaps we should also renew the R versions as well (in another PR) ? 4.6 is coming up. r-universe builds normally do devel, release and old_release ... thus now it would be 4.6, 4.5 and 4.4.

@Artur-man
Copy link
Copy Markdown
Collaborator Author

Artur-man commented Apr 7, 2026

lastly, now we hard code the SITKTAG but normally should be parsed from DESCRIPTION:

Package: SimpleITK
Version: 2.5.3

How do you wanna do this @blowekamp ? I can update both configure and configure.win to pre-release since 3.0.0 is not fully out yet ? In that case we should hardcode SITKTAG to the hash 1899b2 in configuration which cannot be placed and parsed from Version field of DESCRIPTION.

export SITKTAG=v$(Rscript -e "cat(desc::desc_get_field('Version', file='DESCRIPTION'))")

Here is the message you gonna get when you put a versioning that R does not like, happens before the build:

The downloaded source packages are in
	‘/tmp/Rtmp1SjK7n/downloaded_packages’
Running `R CMD build`...
* checking for file ‘/tmp/Rtmp1SjK7n/file1a077287fe71/DESCRIPTION’ ... OK
* preparing ‘SimpleITK’:
* checking DESCRIPTION meta-information ... ERROR
Error: Malformed package version.

@blowekamp
Copy link
Copy Markdown
Member

blowekamp commented Apr 7, 2026

It should like hard coding SITKTAG is easiest to get things working and merged at this point.

P.S. Also please squash all you commits. I think only one is needed in the repo's history.

Add support for building and testing on Windows OS
in a consistent manner to Linux and macOS. On
Windows, this uses RTools to provide the necessary
build tools. Testing is performed in CircleCI as
it offers a more powerful build machine under
the free plan.

Co-authored-by: Artur-man <artur-man@hotmail.com>
@Artur-man Artur-man force-pushed the addWindowsSupport branch from 289e9fc to 8a6edc6 Compare April 7, 2026 20:53
@Artur-man
Copy link
Copy Markdown
Collaborator Author

Artur-man commented Apr 7, 2026

This the first time I rebased ever :D let me know if it worked.

@blowekamp blowekamp requested a review from zivy April 8, 2026 16:54
Copy link
Copy Markdown
Member

@zivy zivy left a comment

Choose a reason for hiding this comment

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

@Artur-man Thank you for this significant contribution to the SimpleITK ecosystem 🎉 ✨

Having the installer work on windows will significantly increase the availability of SimpleITK to the R community, supporting imaging research from micro-scale 🔬, through meso-scale 🧠, to macro-scale 🔭

@blowekamp blowekamp self-requested a review April 8, 2026 17:17
@blowekamp blowekamp merged commit c308415 into SimpleITK:main Apr 8, 2026
7 checks passed
@Artur-man
Copy link
Copy Markdown
Collaborator Author

thanks guys @blowekamp @zivy @richardbeare
I enjoyed working on this with you. Soon I will also explore options across CRAN and R-universe again.

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.

win GHA runner

4 participants