Skip to content

Commit b2a292e

Browse files
committed
Added windows workflow
1 parent 9eb9e9c commit b2a292e

7 files changed

Lines changed: 181 additions & 131 deletions

File tree

.github/workflows/python-bindings.yml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@ jobs:
1414
name: "Test python bindings"
1515
strategy:
1616
matrix:
17-
on: [ 'ubuntu-24.04', 'macos-15-intel' , 'macos-26' ]
17+
on: [ 'ubuntu-24.04', 'macos-15-intel', 'macos-26', 'windows-2022', 'windows-2025' ]
1818
python: [ '3.10', '3.11', '3.12', '3.13' ]
1919

2020
runs-on: ${{matrix.on}}
2121
env:
22-
INSTALL_PREFIX: "/usr/local"
22+
INSTALL_PREFIX: ${{ startsWith(matrix.on, 'windows-') && format('{0}\install', github.workspace) || '/usr/local' }}
2323

2424
steps:
2525
- uses: actions/checkout@v4
2626
- uses: actions/setup-python@v6
2727
with:
2828
python-version: ${{matrix.python}}
29+
2930
- name: "Install packages ubuntu"
3031
if: ${{ startsWith(matrix.on, 'ubuntu-') }}
3132
run: sudo apt install -y ninja-build g++
@@ -38,7 +39,13 @@ jobs:
3839
if: ${{ startsWith(matrix.on, 'macos-') }}
3940
run: brew install ninja gcc cmake
4041

41-
- name: "Run CMake"
42+
- name: "Install Windows packages"
43+
if: ${{ startsWith(matrix.on, 'windows-') }}
44+
shell: pwsh
45+
run: choco install cmake ninja --yes --installargs 'ADD_CMAKE_TO_PATH=System'
46+
47+
- name: "Run CMake (UNIX)"
48+
if: ${{ !startsWith(matrix.on, 'windows-') }}
4249
run: |
4350
cmake -DCMAKE_BUILD_TYPE=Release \
4451
-G Ninja \
@@ -47,11 +54,34 @@ jobs:
4754
cmake --build ../build -j $(nproc)
4855
sudo cmake --install ../build --prefix $INSTALL_PREFIX
4956
57+
- name: "Run CMake (Windows)"
58+
if: ${{ startsWith(matrix.on, 'windows-') }}
59+
shell: pwsh
60+
run: |
61+
cmake -G "Ninja" `
62+
-DCMAKE_BUILD_TYPE=Release `
63+
-DCMAKE_INSTALL_PREFIX="$install_prefix" `
64+
-B ../build `
65+
-S $env:GITHUB_WORKSPACE
66+
cmake --build ../build --parallel
67+
cmake --install ../build
68+
5069
- name: "Install python test environment"
51-
run: python -m pip install -r ${GITHUB_WORKSPACE}/test-requirement.txt
70+
run: python -m pip install -r test-requirement.txt
71+
72+
- name: "Run Python tests (WINDOWS)"
73+
if: ${{ startsWith(matrix.on, 'windows-') }}
74+
shell: bash
75+
run: |
76+
PYBIND_FILE=$(ls $INSTALL_PREFIX\\lib\\python\\py_capio_cl*.pyd | head -n 1)
77+
export CAPIO_CL_PY_BINDING_PATH=$(cygpath -m "$PYBIND_FILE")
78+
echo "Python module path: $CAPIO_CL_PY_BINDING_PATH"
79+
pytest tests/python/test_*
5280
53-
- name: "Run python tests"
81+
- name: "Run Python tests (UNIX)"
82+
if: ${{ !startsWith(matrix.on, 'windows-') }}
83+
shell: bash
5484
run: |
5585
export CAPIO_CL_PY_BINDING_PATH=$(realpath $INSTALL_PREFIX/lib/python/py_capio_cl*)
56-
echo "Python module path: $CAPIO_CL_PY_BINDING_PATH"
86+
echo "Python module path: $CAPIO_CL_PY_BINDING_PATH"
5787
pytest ${GITHUB_WORKSPACE}/tests/python/test_*

CMakeLists.txt

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,33 @@ if (BUILD_PYTHON_BINDINGS)
8787
)
8888

8989

90-
# Make sure the binding sees the CAPIO CL headers & links against the core lib
9190
target_link_libraries(${PYTHON_BIND_NAME}
9291
PRIVATE libcapio_cl
9392
)
9493

94+
if (WIN32)
95+
target_link_libraries(py_capio_cl PRIVATE ws2_32 shlwapi)
96+
endif ()
97+
98+
9599
target_include_directories(${PYTHON_BIND_NAME}
96100
PRIVATE
97101
${CMAKE_CURRENT_SOURCE_DIR}
98102
)
99103

100-
install(TARGETS ${PYTHON_BIND_NAME}
101-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/python
102-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/python
103-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
104-
)
104+
if (WIN32)
105+
install(TARGETS ${PYTHON_BIND_NAME}
106+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}\\python
107+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}\\python
108+
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}\\python
109+
)
110+
else ()
111+
install(TARGETS ${PYTHON_BIND_NAME}
112+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/python
113+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/python
114+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
115+
)
116+
endif ()
105117

106118
endif ()
107119

@@ -128,6 +140,10 @@ if (CAPIO_CL_BUILD_TESTS)
128140
GTest::gtest_main
129141
)
130142

143+
if (WIN32)
144+
target_link_libraries(CAPIO_CL_tests PRIVATE ws2_32 shlwapi)
145+
endif ()
146+
131147
target_include_directories(CAPIO_CL_tests PRIVATE
132148
${CMAKE_CURRENT_SOURCE_DIR}
133149
${CMAKE_CURRENT_SOURCE_DIR}/src

0 commit comments

Comments
 (0)