Skip to content

Commit dc3e80e

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

7 files changed

Lines changed: 185 additions & 134 deletions

File tree

.github/workflows/python-bindings.yml

Lines changed: 35 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,33 @@ 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+
-B ../build `
64+
-S $env:GITHUB_WORKSPACE
65+
cmake --build ../build --parallel
66+
cmake --install ../build --prefix $env:INSTALL_PREFIX
67+
5068
- name: "Install python test environment"
51-
run: python -m pip install -r ${GITHUB_WORKSPACE}/test-requirement.txt
69+
run: python -m pip install -r test-requirement.txt
70+
71+
- name: "Run Python tests (WINDOWS)"
72+
if: ${{ startsWith(matrix.on, 'windows-') }}
73+
shell: bash
74+
run: |
75+
PYBIND_FILE=$INSTALL_PREFIX\\lib\\python\\$(dir $INSTALL_PREFIX\\lib\\python | head -n 1)
76+
export CAPIO_CL_PY_BINDING_PATH=$(cygpath -m "$PYBIND_FILE")
77+
echo "Python module path: $CAPIO_CL_PY_BINDING_PATH"
78+
pytest tests/python/test_*
5279
53-
- name: "Run python tests"
80+
- name: "Run Python tests (UNIX)"
81+
if: ${{ !startsWith(matrix.on, 'windows-') }}
82+
shell: bash
5483
run: |
5584
export CAPIO_CL_PY_BINDING_PATH=$(realpath $INSTALL_PREFIX/lib/python/py_capio_cl*)
56-
echo "Python module path: $CAPIO_CL_PY_BINDING_PATH"
85+
echo "Python module path: $CAPIO_CL_PY_BINDING_PATH"
5786
pytest ${GITHUB_WORKSPACE}/tests/python/test_*

CMakeLists.txt

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,35 @@ if (BUILD_PYTHON_BINDINGS)
8787
)
8888

8989

90-
# Make sure the binding sees the CAPIO CL headers & links against the core lib
91-
target_link_libraries(${PYTHON_BIND_NAME}
92-
PRIVATE libcapio_cl
93-
)
90+
91+
92+
if (WIN32)
93+
target_link_libraries(py_capio_cl PRIVATE libcapio_cl ws2_32 shlwapi)
94+
else()
95+
target_link_libraries(${PYTHON_BIND_NAME}
96+
PRIVATE libcapio_cl
97+
)
98+
endif ()
99+
94100

95101
target_include_directories(${PYTHON_BIND_NAME}
96102
PRIVATE
97103
${CMAKE_CURRENT_SOURCE_DIR}
98104
)
99105

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-
)
106+
if (WIN32)
107+
install(TARGETS ${PYTHON_BIND_NAME}
108+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}\\python
109+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}\\python
110+
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}\\python
111+
)
112+
else ()
113+
install(TARGETS ${PYTHON_BIND_NAME}
114+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/python
115+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/python
116+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
117+
)
118+
endif ()
105119

106120
endif ()
107121

@@ -128,6 +142,10 @@ if (CAPIO_CL_BUILD_TESTS)
128142
GTest::gtest_main
129143
)
130144

145+
if (WIN32)
146+
target_link_libraries(CAPIO_CL_tests PRIVATE ws2_32 shlwapi)
147+
endif ()
148+
131149
target_include_directories(CAPIO_CL_tests PRIVATE
132150
${CMAKE_CURRENT_SOURCE_DIR}
133151
${CMAKE_CURRENT_SOURCE_DIR}/src

0 commit comments

Comments
 (0)