Skip to content

Commit b843dab

Browse files
authored
Merge pull request #3 from fzhem/windows-workflow
Windows workflow
2 parents 3c76c57 + 2bd4d68 commit b843dab

5 files changed

Lines changed: 297 additions & 2 deletions

File tree

.github/workflows/linux.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
name: Linux
1+
name: Linux Wheels
22

33
on:
44
workflow_dispatch:
5+
workflow_call:
56

67
jobs:
78
compose-job:

.github/workflows/release.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
linux:
8+
uses: ./.github/workflows/linux.yml
9+
10+
windows:
11+
uses: ./.github/workflows/windows.yml
12+
13+
release:
14+
needs: [linux, windows]
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Download Linux wheels
21+
uses: actions/download-artifact@v4
22+
with:
23+
name: linux-wheels
24+
path: wheelhouse
25+
26+
- name: Download Windows wheels
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: windows-wheels
30+
path: wheelhouse
31+
32+
- name: Get latest commit hash
33+
id: get_commit_hash
34+
run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
35+
36+
- name: Create GitHub Release
37+
uses: softprops/action-gh-release@v2
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
with:
41+
files: wheelhouse/*.whl
42+
draft: true
43+
body: Built and released from orchestrator workflow.
44+
tag_name: ${{ steps.get_commit_hash.outputs.hash }}

.github/workflows/windows.yml

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
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

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)