Skip to content

Commit 5162dc8

Browse files
committed
[#246]:svarga:fix, package.yml macOS HDF5 discovery + Windows build-from-source
Two platform fixes in the same workflow file, both required for the v1.12.5 Package run to produce assets across the full matrix. macOS (#245): The Configure step set HDF5_ROOT from brew --prefix but FindHDF5 on macos-15 / Apple Silicon needed CMAKE_PREFIX_PATH as well to locate the C library, producing: Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS C) ci.yml's macOS path sets both; package.yml only set one. Symmetrised. Windows (#246): choco install hdf5 returns "package not found" — there is no hdf5 package in the Chocolatey community repo. The #236 fix that introduced this command was based on an incorrect assumption. Replaced with the build-from-source pattern already validated by ci.yml's Windows path: - Build zlib 1.3.1 from source (~30s, not cached) - Restore HDF5 1.12.2 cache if present - Build HDF5 1.12.2 from source if cache-miss (~3-5min, cached) - Save HDF5 cache on miss Configure now consumes both prefixes through CMAKE_PREFIX_PATH. The first run after this change will be slow (~5min for HDF5 build); subsequent runs reuse the cache.
1 parent 9abd0dd commit 5162dc8

1 file changed

Lines changed: 84 additions & 3 deletions

File tree

.github/workflows/package.yml

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ jobs:
8686

8787
- name: Configure
8888
run: |
89+
HDF5_PREFIX="$(brew --prefix hdf5)"
8990
cmake -B build \
9091
-DCMAKE_BUILD_TYPE=Release \
9192
-DCMAKE_INSTALL_PREFIX=/usr/local \
92-
-DHDF5_ROOT=$(brew --prefix hdf5) \
93+
-DHDF5_ROOT="$HDF5_PREFIX" \
94+
-DCMAKE_PREFIX_PATH="$HDF5_PREFIX" \
9395
-DH5CPP_BUILD_EXAMPLES=OFF \
9496
-DH5CPP_BUILD_TESTS=OFF \
9597
-DH5CPP_BUILD_BENCH=OFF
@@ -107,21 +109,100 @@ jobs:
107109
if-no-files-found: error
108110

109111
# ── Windows (NSIS .exe) ───────────────────────────────────────────────────────
112+
# No Chocolatey 'hdf5' package exists; mirror the build-from-source approach
113+
# from ci.yml. zlib is built fresh each run (~30s); HDF5 install prefix is
114+
# cached between runs.
110115
package-windows:
111116
name: windows / x64 / NSIS
112117
runs-on: windows-latest
118+
env:
119+
HDF5_VERSION: 1.12.2
120+
HDF5_CACHE_VERSION: v3
113121

114122
steps:
115123
- uses: actions/checkout@v4
116124

117-
- name: Install HDF5
118-
run: choco install hdf5 -y --no-progress
125+
- name: Build zlib from source
126+
shell: powershell
127+
run: |
128+
$ErrorActionPreference = "Stop"
129+
$zlib_version = "1.3.1"
130+
$zlib_archive = "$env:RUNNER_TEMP\zlib-$zlib_version.tar.gz"
131+
$zlib_source = "$env:RUNNER_TEMP\zlib-$zlib_version"
132+
$zlib_build = "$env:RUNNER_TEMP\zlib-build"
133+
$zlib_prefix = "$env:RUNNER_TEMP\zlib-install"
134+
135+
Invoke-WebRequest `
136+
-Uri "https://github.com/madler/zlib/archive/refs/tags/v$zlib_version.tar.gz" `
137+
-OutFile $zlib_archive
138+
tar -xzf $zlib_archive -C $env:RUNNER_TEMP
139+
140+
cmake -S $zlib_source -B $zlib_build `
141+
-G "Visual Studio 17 2022" -A x64 `
142+
-DCMAKE_INSTALL_PREFIX="$zlib_prefix"
143+
cmake --build $zlib_build --parallel --config Release
144+
cmake --install $zlib_build --config Release
145+
146+
- name: Restore HDF5 cache
147+
id: cache-hdf5
148+
uses: actions/cache/restore@v5
149+
with:
150+
path: ${{ runner.temp }}\hdf5-${{ env.HDF5_VERSION }}-install
151+
key: hdf5-windows-vs2022-${{ env.HDF5_VERSION }}-pkg-${{ env.HDF5_CACHE_VERSION }}
152+
153+
- name: Build HDF5 from source
154+
if: steps.cache-hdf5.outputs.cache-hit != 'true'
155+
shell: powershell
156+
run: |
157+
$ErrorActionPreference = "Stop"
158+
$hdf5_version = "${{ env.HDF5_VERSION }}"
159+
$hdf5_archive = "$env:RUNNER_TEMP\hdf5-$hdf5_version.tar.gz"
160+
$hdf5_source = "$env:RUNNER_TEMP\hdf5-$hdf5_version"
161+
$hdf5_build = "$env:RUNNER_TEMP\hdf5-$hdf5_version-build"
162+
$hdf5_prefix = "$env:RUNNER_TEMP\hdf5-$hdf5_version-install"
163+
164+
Invoke-WebRequest `
165+
-Uri "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-$hdf5_version/src/hdf5-$hdf5_version.tar.gz" `
166+
-OutFile $hdf5_archive
167+
tar -xzf $hdf5_archive -C $env:RUNNER_TEMP
168+
169+
cmake -S $hdf5_source -B $hdf5_build `
170+
-G "Visual Studio 17 2022" -A x64 `
171+
-DCMAKE_INSTALL_PREFIX="$hdf5_prefix" `
172+
-DHDF_CFG_NAME=Release `
173+
-DBUILD_SHARED_LIBS=ON `
174+
-DBUILD_TESTING=OFF `
175+
-DHDF5_BUILD_TOOLS=OFF `
176+
-DHDF5_BUILD_UTILS=OFF `
177+
-DHDF5_BUILD_EXAMPLES=OFF `
178+
-DHDF5_BUILD_CPP_LIB=OFF `
179+
-DHDF5_BUILD_HL_LIB=OFF `
180+
-DHDF5_BUILD_FORTRAN=OFF `
181+
-DHDF5_ENABLE_Z_LIB_SUPPORT=ON `
182+
-DHDF5_ENABLE_SZIP_SUPPORT=OFF `
183+
-DZLIB_USE_EXTERNAL=OFF `
184+
-DZLIB_INCLUDE_DIR="$env:RUNNER_TEMP/zlib-install/include" `
185+
-DZLIB_LIBRARY="$env:RUNNER_TEMP/zlib-install/lib/zlib.lib"
186+
187+
cmake --build $hdf5_build --parallel --config Release
188+
cmake --install $hdf5_build --config Release
189+
190+
- name: Save HDF5 cache
191+
if: steps.cache-hdf5.outputs.cache-hit != 'true'
192+
uses: actions/cache/save@v5
193+
with:
194+
path: ${{ runner.temp }}\hdf5-${{ env.HDF5_VERSION }}-install
195+
key: ${{ steps.cache-hdf5.outputs.cache-primary-key }}
119196

120197
- name: Configure
121198
shell: pwsh
122199
run: |
200+
$hdf5_prefix = "$env:RUNNER_TEMP/hdf5-${{ env.HDF5_VERSION }}-install"
201+
$zlib_prefix = "$env:RUNNER_TEMP/zlib-install"
123202
cmake -B build `
124203
-DCMAKE_BUILD_TYPE=Release `
204+
-DHDF5_ROOT="$hdf5_prefix" `
205+
-DCMAKE_PREFIX_PATH="$hdf5_prefix;$zlib_prefix" `
125206
-DH5CPP_BUILD_EXAMPLES=OFF `
126207
-DH5CPP_BUILD_TESTS=OFF `
127208
-DH5CPP_BUILD_BENCH=OFF `

0 commit comments

Comments
 (0)