Skip to content

Commit 060bb0b

Browse files
committed
ci: add win32 wheel
1 parent 590786e commit 060bb0b

File tree

1 file changed

+51
-3
lines changed

1 file changed

+51
-3
lines changed

.github/workflows/ci-wheels.yml

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ jobs:
5252
incdir: /opt/homebrew/Cellar/udunits/2.2.28/include
5353
libdir: /opt/homebrew/Cellar/udunits/2.2.28/lib
5454
xml_path: /opt/homebrew/Cellar/udunits/2.2.28/share/udunits/udunits2-common.xml
55+
- os: "windows-latest"
56+
arch: "AMD64"
57+
xml_path: "C:/lib/share/udunits/udunits2.xml"
58+
incdir: C:/lib/include/
59+
libdir: C:/lib/lib/
5560
exclude:
5661
- os: "ubuntu-latest"
5762
arch: "arm64"
@@ -69,6 +74,41 @@ jobs:
6974
if: startsWith(matrix.os, 'macos')
7075
run: echo "MACOSX_DEPLOYMENT_TARGET=$([[ ${{ matrix.os }} == 'macos-latest' ]] && echo '14.0' || echo '13.0')" >> $GITHUB_ENV
7176

77+
- name: Export GitHub Actions cache environment variables
78+
# https://learn.microsoft.com/en-us/vcpkg/consume/binary-caching-github-actions-cache
79+
if: runner.os == 'Windows'
80+
uses: actions/github-script@v7
81+
with:
82+
script: |
83+
const path = require('path')
84+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
85+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
86+
core.exportVariable('VCPKG_ROOT', process.env.VCPKG_INSTALLATION_ROOT);
87+
88+
- name: "install expat on win32"
89+
if: runner.os == 'Windows'
90+
run: vcpkg install expat:x64-windows
91+
env:
92+
# cache vcpkg
93+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
94+
95+
- name: "setup udunits2 on windows"
96+
if: runner.os == 'Windows'
97+
shell: bash
98+
run: |
99+
set -e -u -o -x pipefail
100+
101+
cd ~/Downloads
102+
C:/msys64/usr/bin/wget.exe https://downloads.unidata.ucar.edu/udunits/2.2.28/udunits-2.2.28.zip
103+
104+
unzip udunits-2.2.28.zip
105+
106+
cd ./udunits-2.2.28/
107+
108+
cmake -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -B build -S . -D CMAKE_INSTALL_PREFIX=C:/lib/ -D CMAKE_BUILD_TYPE=release
109+
cmake --build build --config Release
110+
cmake --install build
111+
72112
- name: "Building ${{ matrix.os }} (${{ matrix.arch }}) wheels"
73113
uses: pypa/[email protected]
74114
env:
@@ -78,14 +118,22 @@ jobs:
78118
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
79119
CIBW_BEFORE_BUILD_LINUX: yum install -y udunits2-devel
80120
CIBW_BEFORE_BUILD_MACOS: brew install udunits
121+
CIBW_BEFORE_BUILD_WINDOWS: python -m pip install delvewheel
81122
CIBW_TEST_REQUIRES: pytest
82-
CIBW_TEST_COMMAND: >
83-
python -c 'import cf_units; print(f"cf-units v{cf_units.__version__}")' &&
84-
python -m pytest --pyargs cf_units
123+
CIBW_TEST_COMMAND: >-
124+
python -c 'import cf_units; print(f"cf-units v{cf_units.__version__}")' && python -m pytest --pyargs cf_units
125+
CIBW_TEST_COMMAND_WINDOWS: python -m pytest --pyargs cf_units
85126
UDUNITS2_INCDIR: ${{ matrix.incdir }}
86127
UDUNITS2_LIBDIR: ${{ matrix.libdir }}
87128
UDUNITS2_XML_PATH: ${{ matrix.xml_path }}
88129
CIBW_ENVIRONMENT_PASS_LINUX: UDUNITS2_INCDIR UDUNITS2_LIBDIR UDUNITS2_XML_PATH
130+
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >-
131+
delvewheel repair -v
132+
--add-path=C:\\lib\\bin\\
133+
--add-path=C:\\lib\\lib\\
134+
--add-path=${{ env.VCPKG_ROOT }}/installed/x64-windows/bin/
135+
--wheel-dir={dest_dir}
136+
{wheel}
89137
90138
- uses: actions/upload-artifact@v4
91139
with:

0 commit comments

Comments
 (0)