Skip to content

Commit 14106e0

Browse files
committed
Add windows workflow
1 parent ef96f9b commit 14106e0

3 files changed

Lines changed: 250 additions & 1 deletion

File tree

.github/workflows/windows.yml

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

CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,22 @@ project(octdata4python LANGUAGES CXX)
33

44
set(CMAKE_CXX_STANDARD 17)
55

6+
# 🔧 Match Boost build config
7+
set(Boost_USE_STATIC_LIBS OFF)
8+
set(Boost_USE_MULTITHREADED ON)
9+
set(Boost_USE_STATIC_RUNTIME OFF)
10+
11+
# Match Boost libs per platform and Python version
12+
if(WIN32)
13+
string(REPLACE "." "" PY_VER "${Python3_VERSION}")
14+
set(BOOST_PYTHON_COMPONENT "python${PY_VER}")
15+
else()
16+
set(BOOST_PYTHON_COMPONENT "python")
17+
endif()
18+
message(STATUS "🐍 Boost.Python component resolved as: ${BOOST_PYTHON_COMPONENT}")
19+
620
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
7-
find_package(Boost COMPONENTS python numpy REQUIRED)
21+
find_package(Boost COMPONENTS ${BOOST_PYTHON_COMPONENT} numpy REQUIRED)
822
find_package(LibOctData REQUIRED)
923
find_package(OpenCV REQUIRED COMPONENTS core)
1024

user-config.jam

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
local PY310ROOT = [ modules.peek : Python310_ROOT_DIR ] ;
2+
local PY311ROOT = [ modules.peek : Python311_ROOT_DIR ] ;
3+
local PY312ROOT = [ modules.peek : Python312_ROOT_DIR ] ;
4+
5+
using python : 3.10 : $(PY310ROOT) : $(PY310ROOT)/include : $(PY310ROOT)/libs ;
6+
using python : 3.11 : $(PY311ROOT) : $(PY311ROOT)/include : $(PY311ROOT)/libs ;
7+
using python : 3.12 : $(PY312ROOT) : $(PY312ROOT)/include : $(PY312ROOT)/libs ;

0 commit comments

Comments
 (0)