|
| 1 | +name: Windows Wheels |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + workflow_call: |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + permissions: |
| 10 | + contents: write |
| 11 | + runs-on: windows-2025 |
| 12 | + |
| 13 | + env: |
| 14 | + Boost_DIR: C:/Boost/lib/cmake/Boost-1.88.0 |
| 15 | + DCMTK_DIR: C:/tools/dcmtk-20241211-ac00290 |
| 16 | + OpenCV_DIR: C:/tools/opencv/build |
| 17 | + OpenJPEG_DIR: C:/Program Files (x86)/OPENJPEG |
| 18 | + Python310_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.10.11\x64 |
| 19 | + Python311_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.11.9\x64 |
| 20 | + Python312_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.12.10\x64 |
| 21 | + Python313_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.13.3\x64 |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout main repo |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Install dependencies (numpy needed for boost) |
| 28 | + run: | |
| 29 | + $versions = @("Python310", "Python311", "Python312") |
| 30 | + foreach ($v in $versions) { |
| 31 | + $root = (Get-Item "env:${v}_ROOT_DIR").Value |
| 32 | + & "$root\python.exe" -m pip install --upgrade pip setuptools wheel |
| 33 | + & "$root\Scripts\pip.exe" install numpy==1.26.0 |
| 34 | + } |
| 35 | +
|
| 36 | + - name: Clone required forks |
| 37 | + run: | |
| 38 | + mkdir C:/repos; if ($?) { cd C:/repos } |
| 39 | + git clone https://github.com/kaygdev/oct_cpp_framework.git |
| 40 | + git clone https://github.com/kaygdev/LibE2E.git |
| 41 | + git clone https://github.com/fzhem/LibOctData.git |
| 42 | + git clone https://github.com/fzhem/octdata4python.git |
| 43 | +
|
| 44 | + - name: Add missing boost find_package |
| 45 | + run: | |
| 46 | + (Get-Content C:/repos/oct_cpp_framework/CMakeLists.txt) -replace 'find_package\(OpenCV REQUIRED\)', "find_package(OpenCV REQUIRED)`r`nfind_package(Boost REQUIRED)" | Set-Content C:/repos/oct_cpp_framework/CMakeLists.txt |
| 47 | + (Get-Content C:/repos/LibE2E/CMakeLists.txt) -replace 'find_package\(OpenCV REQUIRED\)', "find_package(OpenCV REQUIRED)`r`nfind_package(Boost REQUIRED)" | Set-Content C:/repos/LibE2E/CMakeLists.txt |
| 48 | +
|
| 49 | + - name: Restore OpenCV cache |
| 50 | + id: restore-opencv-cache |
| 51 | + uses: actions/cache/restore@v4 |
| 52 | + with: |
| 53 | + key: opencv-4.11.0-windows-${{ runner.os }} |
| 54 | + path: C:/tools/opencv |
| 55 | + |
| 56 | + - name: Install OpenCV via Chocolatey |
| 57 | + if: steps.restore-opencv-cache.outputs.cache-hit != 'true' |
| 58 | + run: choco install opencv --version=4.11.0 -y --no-progress |
| 59 | + |
| 60 | + - name: Save OpenCV cache |
| 61 | + uses: actions/cache/save@v4 |
| 62 | + if: steps.restore-opencv-cache.outputs.cache-hit != 'true' |
| 63 | + with: |
| 64 | + key: opencv-4.11.0-windows-${{ runner.os }} |
| 65 | + path: C:/tools/opencv |
| 66 | + |
| 67 | + - name: Download Zlib from source |
| 68 | + run: | |
| 69 | + curl -L -o C:/tools/zlib.zip https://zlib.net/zlib131.zip |
| 70 | + tar -xf C:/tools/zlib.zip -C C:/tools |
| 71 | +
|
| 72 | + - name: Build Zlib |
| 73 | + shell: cmd |
| 74 | + run: | |
| 75 | + cd /d C:/tools/zlib-1.3.1 |
| 76 | + mkdir build && cd build |
| 77 | + cmake .. -G "Visual Studio 17 2022" |
| 78 | + cmake --build . --config Release --target install |
| 79 | +
|
| 80 | + - name: Restore Boost zip cache |
| 81 | + id: restore-boost-zip-cache |
| 82 | + uses: actions/cache/restore@v4 |
| 83 | + with: |
| 84 | + key: boost-1.88.0-zip-${{ runner.os }} |
| 85 | + path: C:/tools/boost.zip |
| 86 | + |
| 87 | + - name: Download Boost from source |
| 88 | + if: steps.restore-boost-zip-cache.outputs.cache-hit != 'true' |
| 89 | + run: | |
| 90 | + curl -L -o C:/tools/boost.zip https://archives.boost.io/release/1.88.0/source/boost_1_88_0.zip |
| 91 | + mkdir C:/local |
| 92 | + tar -xf C:/tools/boost.zip -C C:/local |
| 93 | +
|
| 94 | + - name: Save Boost zip cache |
| 95 | + uses: actions/cache/save@v4 |
| 96 | + if: steps.restore-boost-zip-cache.outputs.cache-hit != 'true' |
| 97 | + with: |
| 98 | + key: boost-1.88.0-zip-${{ runner.os }} |
| 99 | + path: C:/tools/boost.zip |
| 100 | + |
| 101 | + - name: Restore Boost build cache |
| 102 | + id: restore-boost-build-cache |
| 103 | + uses: actions/cache/restore@v4 |
| 104 | + with: |
| 105 | + key: boost-1.88.0-build-${{ runner.os }} |
| 106 | + path: C:/Boost |
| 107 | + |
| 108 | + - name: Run Boost Bootstrap Script |
| 109 | + if: steps.restore-boost-build-cache.outputs.cache-hit != 'true' |
| 110 | + shell: cmd |
| 111 | + run: | |
| 112 | + cd /d C:/local/boost_1_88_0 |
| 113 | + bootstrap.bat |
| 114 | +
|
| 115 | + - name: Build and Install Boost Libraries |
| 116 | + env: |
| 117 | + BOOST_BUILD_PATH: ${{ github.workspace }} |
| 118 | + if: steps.restore-boost-build-cache.outputs.cache-hit != 'true' |
| 119 | + shell: cmd |
| 120 | + run: | |
| 121 | + cd /d C:/local/boost_1_88_0 |
| 122 | + b2 -j%NUMBER_OF_PROCESSORS% ^ |
| 123 | + toolset=msvc-14.3 address-model=64 variant=release link=shared threading=multi runtime-link=shared ^ |
| 124 | + python=3.10,3.11,3.12 ^ |
| 125 | + --with-iostreams --with-locale --with-log --with-python --with-program_options --with-serialization ^ |
| 126 | + --debug-configuration ^ |
| 127 | + --prefix=C:/Boost install |
| 128 | +
|
| 129 | + - name: Save Boost build cache |
| 130 | + uses: actions/cache/save@v4 |
| 131 | + if: steps.restore-boost-build-cache.outputs.cache-hit != 'true' |
| 132 | + with: |
| 133 | + key: boost-1.88.0-build-${{ runner.os }} |
| 134 | + path: C:/Boost |
| 135 | + |
| 136 | + - name: Clone OpenJPEG |
| 137 | + run: | |
| 138 | + cd C:/repos |
| 139 | + git clone --branch v2.5.3 https://github.com/uclouvain/openjpeg.git |
| 140 | +
|
| 141 | + - name: Build OpenJPEG |
| 142 | + run: | |
| 143 | + cd C:/repos/openjpeg |
| 144 | + cmake -G "Visual Studio 17 2022" . |
| 145 | + cmake --build . --config Release --target install |
| 146 | +
|
| 147 | + - name: Download libtiff from source |
| 148 | + run: | |
| 149 | + curl -L -o C:/tools/tiff.zip https://download.osgeo.org/libtiff/tiff-4.7.0.zip |
| 150 | + tar -xf C:/tools/tiff.zip -C C:/tools |
| 151 | +
|
| 152 | + - name: Build libtiff |
| 153 | + shell: cmd |
| 154 | + run: | |
| 155 | + cd /d C:/tools/tiff-4.7.0 |
| 156 | + cmake -G "Visual Studio 17 2022" . |
| 157 | + cmake --build . --config Release --target install |
| 158 | +
|
| 159 | + - name: Download DCMTK |
| 160 | + shell: cmd |
| 161 | + run: | |
| 162 | + curl -L -o C:/tools/dcmtk.zip https://github.com/DCMTK/dcmtk/releases/download/DCMTK-3.6.9/dcmtk-20241211-ac00290-win64.zip |
| 163 | + tar -xf C:/tools/dcmtk.zip -C C:/tools |
| 164 | + mkdir C:\dcmtk_support\libs\zlib-1.3\lib |
| 165 | + copy C:\tools\zlib-1.3.1\build\Release\zlib.lib C:\dcmtk_support\libs\zlib-1.3\lib\zlib_o.lib |
| 166 | +
|
| 167 | + - name: Build oct_cpp_framework |
| 168 | + run: | |
| 169 | + cd C:/repos/oct_cpp_framework |
| 170 | + mkdir build && cd build |
| 171 | + cmake -G "Visual Studio 17 2022" .. |
| 172 | + cmake --build . --config Release |
| 173 | +
|
| 174 | + - name: Build LibE2E |
| 175 | + run: | |
| 176 | + cd C:/repos/LibE2E |
| 177 | + mkdir build && cd build |
| 178 | + cmake -G "Visual Studio 17 2022" .. |
| 179 | + cmake --build . --config Release |
| 180 | +
|
| 181 | + - name: Build LibOctData |
| 182 | + run: | |
| 183 | + cd C:/repos/LibOctData |
| 184 | + mkdir build && cd build |
| 185 | + cmake -G "Visual Studio 17 2022" ` |
| 186 | + -DBUILD_WITH_SUPPORT_DICOM=ON ` |
| 187 | + -DCMAKE_CXX_FLAGS="/Zc:__cplusplus /DNOMINMAX /EHsc" ` |
| 188 | + -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON .. |
| 189 | + cmake --build . --config Release --target install |
| 190 | +
|
| 191 | + - name: Build octdata4python wheels |
| 192 | + env: |
| 193 | + TIFF_RELEASE: C:/tools/tiff-4.7.0/libtiff/Release |
| 194 | + ZLIB_RELEASE: C:/tools/zlib-1.3.1/build/Release |
| 195 | + run: | |
| 196 | + cd C:/repos/octdata4python |
| 197 | + powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" |
| 198 | + $env:Path = "C:\Users\runneradmin\.local\bin;$env:Path" |
| 199 | + |
| 200 | + $pyVersions = @("3.10", "3.11", "3.12") |
| 201 | + foreach ($ver in $pyVersions) { |
| 202 | + echo "🌀 Syncing with Python $ver..." |
| 203 | + uv sync --python=$ver |
| 204 | +
|
| 205 | + echo "📦 Building wheel for Python $ver..." |
| 206 | + $env:CMAKE_ARGS = "-DPython3_VERSION=$ver" |
| 207 | + .venv/Scripts/python -m build --installer=uv |
| 208 | +
|
| 209 | + echo "🛠️ Repairing wheels for Python $ver..." |
| 210 | + $cp = $ver -replace '\.', '' |
| 211 | + .venv/Scripts/delvewheel repair dist/octdata4python-*-cp$cp-cp$cp-*.whl ` |
| 212 | + --add-path=C:/repos/LibOctData/build/Release ` |
| 213 | + --add-path=C:/Boost/lib ` |
| 214 | + --add-path=$env:OpenCV_DIR/x64/vc16/bin ` |
| 215 | + --add-path=$env:OpenJPEG_DIR/bin ` |
| 216 | + --add-path=$env:TIFF_RELEASE ` |
| 217 | + --add-path=$env:ZLIB_RELEASE ` |
| 218 | + --add-path=$env:DCMTK_DIR/bin |
| 219 | + } |
| 220 | +
|
| 221 | + - name: Fetch latest commit hash |
| 222 | + id: get_commit_hash |
| 223 | + run: echo "hash=$(git rev-parse --short HEAD)" >> $ENV:GITHUB_OUTPUT |
| 224 | + |
| 225 | + - name: Upload Windows wheels |
| 226 | + uses: actions/upload-artifact@v4 |
| 227 | + with: |
| 228 | + name: windows-wheels |
| 229 | + path: C:/repos/octdata4python/wheelhouse/*.whl |
0 commit comments