Repository navigation
Expand file tree
/
Copy pathwindows-download-cache-and-build-module-wheels.ps1
More file actions
134 lines (121 loc) · 5.64 KB
/
Copy pathwindows-download-cache-and-build-module-wheels.ps1
File metadata and controls
134 lines (121 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
########################################################################
# Pull build dependencies and build an ITK external module.
#
# This script must be run in an x64 Developer Powershell.
# See https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022#developer-powershell
#
# -----------------------------------------------------------------------
# Positional parameters:
# - 0th parameter or -python_version_minor option: Python minor version.
# For instance, for Python 3.11:
# > windows-download-cache-and-build-module-wheels.ps1 11
# or equivalently:
# > windows-download-cache-and-build-module-wheels.ps1 -python_version_minor 11
#
# - 1st parameter or -setup_options: pyproject.toml options.
# For instance, for Python 3.11, excluding nvcuda.dll during packaging:
# > windows-download-cache-and-build-module-wheels.ps1 11 "--exclude-libs nvcuda.dll"
# or equivalently:
# > windows-download-cache-and-build-module-wheels.ps1 -python_version_minor 11 -setup_options "--exclude-libs nvcuda.dll"
#
# - 2nd parameter or -cmake_options: CMake options passed to pyproject.tom for project configuration.
# 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"
# or equivalently:
# > windows-download-cache-and-build-module-wheels.ps1 -python_version_minor 11 -setup_options "--exclude-libs nvcuda.dll" -cmake-options "-DRTK_USE_CUDA:BOOL=ON"
#
#
# -----------------------------------------------------------------------
# Environment variables used in this script:
#
# `$env:ITK_PACKAGE_VERSION`: Tag for ITKPythonBuilds build archive to use
#
# `$env:ITKPYTHONPACKAGE_TAG`: Tag for ITKPythonPackage build scripts to use.
# If ITKPYTHONPACKAGE_TAG is empty then the default scripts distributed
# with the ITKPythonBuilds archive will be used.
#
# `$env:ITKPYTHONPACKAGE_ORG`: Github organization or user to use for ITKPythonPackage
# build script source. Default is InsightSoftwareConsortium.
# Ignored if ITKPYTHONPACKAGE_TAG is empty.
#
# `$env:ITK_MODULE_PREQ`: Delimited list of ITK module dependencies to build before building the target module.
# Format is `<org_name>/<module_name>@<module_tag>:<org_name>/<module_name>@<module_tag>:...`.
# For instance, `export ITK_MODULE_PREQ=InsightSoftwareConsortium/ITKMeshToPolyData@v0.10.0`
#
########################################################################
param (
[int]$python_version_minor,
[string]$setup_options,
[string]$cmake_options
)
$pythonArch = "64"
$pythonVersion = "3.$python_version_minor"
echo "Pulling Python $pythonVersion-x$pythonArch"
iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/scikit-build/scikit-ci-addons/master/windows/install-python.ps1'))
if (-not $env:ITK_PACKAGE_VERSION) { $env:ITK_PACKAGE_VERSION = 'v5.4.0' }
echo "Fetching build archive $env:ITK_PACKAGE_VERSION"
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
if ($env:ITKPYTHONPACKAGE_TAG) {
if(-not $env:ITKPYTHONPACKAGE_ORG) {
$env:ITKPYTHONPACKAGE_ORG="InsightSoftwareConsortium"
}
echo "Updating build scripts to $env:ITKPYTHONPACKAGE_ORG/ITKPythonPackage@$env:ITKPYTHONPACKAGE_TAG"
pushd C:\P
git clone "https://github.com/$env:ITKPYTHONPACKAGE_ORG/ITKPythonPackage.git" "IPP-tmp"
pushd "IPP-tmp"
git checkout "$env:ITKPYTHONPACKAGE_TAG"
git status
popd
Remove-Item -Recurse -Force IPP/scripts/
Copy-Item -Recurse IPP-tmp/scripts IPP/
Copy-Item IPP-tmp/requirements-dev.txt IPP/
Remove-Item -Recurse -Force IPP-tmp/
popd
}
# Get other build dependencies
if (-not (Test-Path doxygen-1.16.1.windows.bin.zip)) {
Invoke-WebRequest -Uri "https://github.com/doxygen/doxygen/releases/download/Release_1_16_1/doxygen-1.16.1.windows.x64.bin.zip" -OutFile "doxygen-1.16.1.windows.bin.zip"
}
7z x doxygen-1.16.1.windows.bin.zip -oC:\P\doxygen -aoa -r
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"
# 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$python_version_minor-x64`""
if ("$setup_options".length -gt 0) {
$build_command = "$build_command $setup_options"
}
if("$cmake_options".length -gt 0) {
$build_command = "$build_command -- $cmake_options"
}
echo $build_command
echo "ITK_MODULE_PREQ: $env:ITK_MODULE_PREQ $ITK_MODULE_PREQ"
if ($env:ITK_MODULE_PREQ) {
$MODULES_LIST = $env:ITK_MODULE_PREQ.split(":")
foreach($MODULE_INFO in $MODULES_LIST) {
$MODULE_ORG = $MODULE_INFO.split("/")[0]
$MODULE_NAME = $MODULE_INFO.split("@")[0].split("/")[1]
$MODULE_TAG = $MODULE_INFO.split("@")[1]
$MODULE_UPSTREAM = "https://github.com/$MODULE_ORG/$MODULE_NAME.git"
echo "Cloning from $MODULE_UPSTREAM"
git clone $MODULE_UPSTREAM
pushd $MODULE_NAME
git checkout $MODULE_TAG
echo "Building $MODULE_NAME"
iex $build_command
popd
Copy-Item $MODULE_NAME/include/* include/
}
}
# Run build scripts
iex $build_command