From 2dca3c865fd717f88bbac035e9e2f98c59ce4c46 Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Tue, 3 Jan 2023 20:42:50 +0100 Subject: [PATCH 1/3] ENH: Pass setup.py and cmake options in PowerShell module script --- ...s-download-cache-and-build-module-wheels.ps1 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/windows-download-cache-and-build-module-wheels.ps1 b/scripts/windows-download-cache-and-build-module-wheels.ps1 index 7679f1f7..1aad1575 100644 --- a/scripts/windows-download-cache-and-build-module-wheels.ps1 +++ b/scripts/windows-download-cache-and-build-module-wheels.ps1 @@ -11,6 +11,14 @@ # # > windows-download-cache-and-build-module-wheels.ps1 11 # +# - other parameters are passed to setup.py. If one of the parameters is "--", +# the following parameters will be passed to cmake. +# For instance, for Python 3.11, excluding nvcuda.dll during packaging +# and setting RTK_USE_CUDA ON during configuration: +# +# > windows-download-cache-and-build-module-wheels.ps1 11 --exclude-libs nvcuda.dll "--" -DRTK_USE_CUDA:BOOL=ON +# +# # ----------------------------------------------------------------------- # Environment variables used in this script: # @@ -71,7 +79,14 @@ $env:Path += ";C:\P\grep" # Build ITK module dependencies, if any $build_command = "& `"C:\Python$pythonVersion-x$pythonArch\python.exe`" `"C:\P\IPP\scripts\windows_build_module_wheels.py`" --no-cleanup --py-envs `"3$($args[0])-x64`"" -echo "Build command: $build_command" +foreach ($arg in $args[1..$args.length]) { + if ($arg.substring(0,2) -eq "--") { + $build_command = "$build_command $($arg)" + } + else { + $build_command = "$build_command `"$($arg)`"" + } +} echo "ITK_MODULE_PREQ: $env:ITK_MODULE_PREQ $ITK_MODULE_PREQ" if ($env:ITK_MODULE_PREQ) { From a3a2311d6340d0689cc88c9d0ae58656ba40832c Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Thu, 5 Jan 2023 12:00:06 +0100 Subject: [PATCH 2/3] ENH: Clean-up existing ITKPythonBuilds-windows.zip extraction This can occur if the same machine is used twice, e.g., a self-hosted runner. --- scripts/windows-download-cache-and-build-module-wheels.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/windows-download-cache-and-build-module-wheels.ps1 b/scripts/windows-download-cache-and-build-module-wheels.ps1 index 1aad1575..73b1751c 100644 --- a/scripts/windows-download-cache-and-build-module-wheels.ps1 +++ b/scripts/windows-download-cache-and-build-module-wheels.ps1 @@ -46,6 +46,9 @@ iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.co if (-not $env:ITK_PACKAGE_VERSION) { $env:ITK_PACKAGE_VERSION = 'v5.3.0' } echo "Fetching build archive $env:ITK_PACKAGE_VERSION" Invoke-WebRequest -Uri "https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/$env:ITK_PACKAGE_VERSION/ITKPythonBuilds-windows.zip" -OutFile "ITKPythonBuilds-windows.zip" +if (Test-Path C:\P) { + Remove-Item -Recurse -Force C:\P +} 7z x ITKPythonBuilds-windows.zip -oC:\P -aoa -r # Optional: Update ITKPythonPackage build scripts From 6a7296422d15a7196f0711faa4ce562d21ba1bf3 Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Thu, 5 Jan 2023 13:12:35 +0100 Subject: [PATCH 3/3] ENH: Only download zip/zst files if they are not already available This was already the case in Linux scripts since 0ea5af0f807940bf10a0a68250bd75532844b0b8. --- ...cpython-download-cache-and-build-module-wheels.sh | 4 +++- ...indows-download-cache-and-build-module-wheels.ps1 | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/macpython-download-cache-and-build-module-wheels.sh b/scripts/macpython-download-cache-and-build-module-wheels.sh index 751ca7f0..40d28e8d 100755 --- a/scripts/macpython-download-cache-and-build-module-wheels.sh +++ b/scripts/macpython-download-cache-and-build-module-wheels.sh @@ -44,7 +44,9 @@ brew upgrade cmake # Fetch ITKPythonBuilds archive containing ITK build artifacts echo "Fetching https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/${ITK_PACKAGE_VERSION:=v5.3.0}/ITKPythonBuilds-macosx.tar.zst" -aria2c -c --file-allocation=none -o ITKPythonBuilds-macosx.tar.zst -s 10 -x 10 https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/${ITK_PACKAGE_VERSION:=v5.3.0}/ITKPythonBuilds-macosx.tar.zst +if [[ ! -f ITKPythonBuilds-macosx.tar.zst ]]; then + aria2c -c --file-allocation=none -o ITKPythonBuilds-macosx.tar.zst -s 10 -x 10 https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/${ITK_PACKAGE_VERSION:=v5.3.0}/ITKPythonBuilds-macosx.tar.zst +fi unzstd --long=31 ITKPythonBuilds-macosx.tar.zst -o ITKPythonBuilds-macosx.tar PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" tar xf ITKPythonBuilds-macosx.tar --checkpoint=10000 --checkpoint-action=dot diff --git a/scripts/windows-download-cache-and-build-module-wheels.ps1 b/scripts/windows-download-cache-and-build-module-wheels.ps1 index 73b1751c..424628d0 100644 --- a/scripts/windows-download-cache-and-build-module-wheels.ps1 +++ b/scripts/windows-download-cache-and-build-module-wheels.ps1 @@ -45,10 +45,12 @@ iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.co if (-not $env:ITK_PACKAGE_VERSION) { $env:ITK_PACKAGE_VERSION = 'v5.3.0' } echo "Fetching build archive $env:ITK_PACKAGE_VERSION" -Invoke-WebRequest -Uri "https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/$env:ITK_PACKAGE_VERSION/ITKPythonBuilds-windows.zip" -OutFile "ITKPythonBuilds-windows.zip" if (Test-Path C:\P) { Remove-Item -Recurse -Force C:\P } +if (-not (Test-Path ITKPythonBuilds-windows.zip)) { + Invoke-WebRequest -Uri "https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/$env:ITK_PACKAGE_VERSION/ITKPythonBuilds-windows.zip" -OutFile "ITKPythonBuilds-windows.zip" +} 7z x ITKPythonBuilds-windows.zip -oC:\P -aoa -r # Optional: Update ITKPythonPackage build scripts @@ -74,9 +76,13 @@ if ($env:ITKPYTHONPACKAGE_TAG) { } # Get other build dependencies -Invoke-WebRequest -Uri "https://data.kitware.com/api/v1/file/5c0ad59d8d777f2179dd3e9c/download" -OutFile "doxygen-1.8.11.windows.bin.zip" +if (-not (Test-Path doxygen-1.8.11.windows.bin.zip)) { + Invoke-WebRequest -Uri "https://data.kitware.com/api/v1/file/5c0ad59d8d777f2179dd3e9c/download" -OutFile "doxygen-1.8.11.windows.bin.zip" +} 7z x doxygen-1.8.11.windows.bin.zip -oC:\P\doxygen -aoa -r -Invoke-WebRequest -Uri "https://data.kitware.com/api/v1/file/5bbf87ba8d777f06b91f27d6/download/grep-win.zip" -OutFile "grep-win.zip" +if (-not (Test-Path grep-win.zip)) { + Invoke-WebRequest -Uri "https://data.kitware.com/api/v1/file/5bbf87ba8d777f06b91f27d6/download/grep-win.zip" -OutFile "grep-win.zip" +} 7z x grep-win.zip -oC:\P\grep -aoa -r $env:Path += ";C:\P\grep"