Skip to content

Commit 9cf9437

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

7 files changed

Lines changed: 182 additions & 127 deletions

File tree

.github/workflows/python-bindings.yml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@ 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+
30+
- name: "Test glob expansion"
31+
if: ${{ startsWith(matrix.on, 'windows-') }}
32+
run: dir $INSTALL_PREFIX\\C*
33+
2934
- name: "Install packages ubuntu"
3035
if: ${{ startsWith(matrix.on, 'ubuntu-') }}
3136
run: sudo apt install -y ninja-build g++
@@ -38,7 +43,13 @@ jobs:
3843
if: ${{ startsWith(matrix.on, 'macos-') }}
3944
run: brew install ninja gcc cmake
4045

41-
- name: "Run CMake"
46+
- name: "Install Windows packages"
47+
if: ${{ startsWith(matrix.on, 'windows-') }}
48+
shell: pwsh
49+
run: choco install cmake ninja --yes --installargs 'ADD_CMAKE_TO_PATH=System'
50+
51+
- name: "Run CMake (UNIX)"
52+
if: ${{ !startsWith(matrix.on, 'windows-') }}
4253
run: |
4354
cmake -DCMAKE_BUILD_TYPE=Release \
4455
-G Ninja \
@@ -47,11 +58,34 @@ jobs:
4758
cmake --build ../build -j $(nproc)
4859
sudo cmake --install ../build --prefix $INSTALL_PREFIX
4960
61+
- name: "Run CMake (Windows)"
62+
if: ${{ startsWith(matrix.on, 'windows-') }}
63+
shell: pwsh
64+
run: |
65+
cmake -G "Ninja" `
66+
-DCMAKE_BUILD_TYPE=Release `
67+
-DCMAKE_INSTALL_PREFIX="$install_prefix" `
68+
-B ../build `
69+
-S $env:GITHUB_WORKSPACE
70+
cmake --build ../build --parallel
71+
cmake --install ../build
72+
5073
- name: "Install python test environment"
51-
run: python -m pip install -r ${GITHUB_WORKSPACE}/test-requirement.txt
74+
run: python -m pip install -r test-requirement.txt
75+
76+
- name: "Run Python tests (WINDOWS)"
77+
if: ${{ startsWith(matrix.on, 'windows-') }}
78+
shell: bash
79+
run: |
80+
PYBIND_FILE=$(ls $INSTALL_PREFIX\\lib\\python\\py_capio_cl*.pyd | head -n 1)
81+
export CAPIO_CL_PY_BINDING_PATH=$(cygpath -m "$PYBIND_FILE")
82+
echo "Python module path: $CAPIO_CL_PY_BINDING_PATH"
83+
pytest tests/python/test_*
5284
53-
- name: "Run python tests"
85+
- name: "Run Python tests (UNIX)"
86+
if: ${{ !startsWith(matrix.on, 'windows-') }}
87+
shell: bash
5488
run: |
5589
export CAPIO_CL_PY_BINDING_PATH=$(realpath $INSTALL_PREFIX/lib/python/py_capio_cl*)
56-
echo "Python module path: $CAPIO_CL_PY_BINDING_PATH"
90+
echo "Python module path: $CAPIO_CL_PY_BINDING_PATH"
5791
pytest ${GITHUB_WORKSPACE}/tests/python/test_*

CMakeLists.txt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,15 @@ 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}
@@ -100,9 +104,18 @@ if (BUILD_PYTHON_BINDINGS)
100104
install(TARGETS ${PYTHON_BIND_NAME}
101105
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/python
102106
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/python
103-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
104107
)
105108

109+
if (WIN32)
110+
install(TARGETS ${PYTHON_BIND_NAME}
111+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/python
112+
)
113+
else ()
114+
install(TARGETS ${PYTHON_BIND_NAME}
115+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
116+
)
117+
endif ()
118+
106119
endif ()
107120

108121

@@ -128,6 +141,10 @@ if (CAPIO_CL_BUILD_TESTS)
128141
GTest::gtest_main
129142
)
130143

144+
if (WIN32)
145+
target_link_libraries(CAPIO_CL_tests PRIVATE ws2_32 shlwapi)
146+
endif ()
147+
131148
target_include_directories(CAPIO_CL_tests PRIVATE
132149
${CMAKE_CURRENT_SOURCE_DIR}
133150
${CMAKE_CURRENT_SOURCE_DIR}/src

0 commit comments

Comments
 (0)