Skip to content

Commit faa82d0

Browse files
authored
adding netcdf4 to main (emscripten-forge#2255)
* adding * pinning
1 parent e699073 commit faa82d0

File tree

10 files changed

+206
-1
lines changed

10 files changed

+206
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
emconfigure ./configure --host=none --disable-parallel4 --disable-dap --disable-dap-remote-tests --disable-nczarr --prefix=$PREFIX
2+
emmake make
3+
emmake make install
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From 4957785c768d6f2816ae989a6acf6e6e84055da8 Mon Sep 17 00:00:00 2001
2+
From: Sam Gardner <sam@wx4stg.com>
3+
Date: Mon, 17 Mar 2025 03:27:16 -0500
4+
Subject: [PATCH] disable hdf5 parallelism
5+
6+
---
7+
libhdf5/hdf5create.c | 16 ++++++++--------
8+
libhdf5/hdf5open.c | 12 ++++++------
9+
2 files changed, 14 insertions(+), 14 deletions(-)
10+
11+
diff --git a/libhdf5/hdf5create.c b/libhdf5/hdf5create.c
12+
index 02cd1b92ed..9a46c5192c 100644
13+
--- a/libhdf5/hdf5create.c
14+
+++ b/libhdf5/hdf5create.c
15+
@@ -198,14 +198,14 @@ nc4_create_file(const char *path, int cmode, size_t initialsz,
16+
H5P_CRT_ORDER_INDEXED)) < 0)
17+
BAIL(NC_EHDFERR);
18+
}
19+
-#ifdef HDF5_HAS_COLL_METADATA_OPS
20+
- /* If HDF5 supports collective metadata operations, turn them
21+
- * on. This is only relevant for parallel I/O builds of HDF5. */
22+
- if (H5Pset_all_coll_metadata_ops(fapl_id, 1) < 0)
23+
- BAIL(NC_EHDFERR);
24+
- if (H5Pset_coll_metadata_write(fapl_id, 1) < 0)
25+
- BAIL(NC_EHDFERR);
26+
-#endif
27+
+// #ifdef HDF5_HAS_COLL_METADATA_OPS
28+
+// /* If HDF5 supports collective metadata operations, turn them
29+
+// * on. This is only relevant for parallel I/O builds of HDF5. */
30+
+// if (H5Pset_all_coll_metadata_ops(fapl_id, 1) < 0)
31+
+// BAIL(NC_EHDFERR);
32+
+// if (H5Pset_coll_metadata_write(fapl_id, 1) < 0)
33+
+// BAIL(NC_EHDFERR);
34+
+// #endif
35+
36+
if (cmode & NC_NODIMSCALE_ATTACH) {
37+
/* See https://github.com/Unidata/netcdf-c/issues/2128 */
38+
diff --git a/libhdf5/hdf5open.c b/libhdf5/hdf5open.c
39+
index 082d528a0a..e2126cf4c6 100644
40+
--- a/libhdf5/hdf5open.c
41+
+++ b/libhdf5/hdf5open.c
42+
@@ -810,12 +810,12 @@ nc4_open_file(const char *path, int mode, void* parameters, int ncid)
43+
}
44+
}
45+
46+
-#ifdef HDF5_HAS_COLL_METADATA_OPS
47+
- /* If collective metadata operations are available in HDF5, turn
48+
- * them on. */
49+
- if (H5Pset_all_coll_metadata_ops(fapl_id, 1) < 0)
50+
- BAIL(NC_EPARINIT);
51+
-#endif /* HDF5_HAS_COLL_METADATA_OPS */
52+
+// #ifdef HDF5_HAS_COLL_METADATA_OPS
53+
+// /* If collective metadata operations are available in HDF5, turn
54+
+// * them on. */
55+
+// if (H5Pset_all_coll_metadata_ops(fapl_id, 1) < 0)
56+
+// BAIL(NC_EPARINIT);
57+
+// #endif /* HDF5_HAS_COLL_METADATA_OPS */
58+
#endif /* USE_PARALLEL4 */
59+
60+
/* Only set cache for non-parallel opens. */
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
From c471b9ce6f726101563f7738844e4dbb7bd6fd7b Mon Sep 17 00:00:00 2001
2+
From: Sam Gardner <sam@wx4stg.com>
3+
Date: Sun, 16 Mar 2025 16:32:35 -0500
4+
Subject: [PATCH] dont use hdf5 parallel if available but not requested
5+
6+
---
7+
configure | 4 +++-
8+
1 file changed, 3 insertions(+), 1 deletion(-)
9+
10+
diff --git a/configure b/configure
11+
index ae48feca8d..7d7f45f85f 100755
12+
--- a/configure
13+
+++ b/configure
14+
@@ -27628,7 +27628,9 @@ printf "%s\n" "#define HDF5_HAS_COLL_METADATA_OPS 1" >>confdefs.h
15+
16+
# If parallel is available in hdf5, enable it in the C code. Also add some stuff to netcdf.h.
17+
if test "x$ac_cv_func_H5Pget_fapl_mpio" = xyes -o "x$ac_cv_func_H5Pget_fapl_mpiposix" = xyes; then
18+
- hdf5_parallel=yes
19+
+ if test "x$enable_parallel" = xyes; then
20+
+ hdf5_parallel=yes
21+
+ fi
22+
fi
23+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether parallel io is enabled in hdf5" >&5
24+
printf %s "checking whether parallel io is enabled in hdf5... " >&6; }
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
context:
2+
version: "4.9.3"
3+
name: "libnetcdf"
4+
5+
package:
6+
name: ${{ name }}
7+
version: ${{ version }}
8+
9+
source:
10+
url: https://github.com/Unidata/netcdf-c/archive/refs/tags/v${{ version }}.tar.gz
11+
sha256: 990f46d49525d6ab5dc4249f8684c6deeaf54de6fec63a187e9fb382cc0ffdff
12+
patches:
13+
- parallel-disable.patch
14+
- hdf5-parallel-disable.patch
15+
build:
16+
number: 0
17+
18+
requirements:
19+
build:
20+
- python
21+
- cross-python_${{ target_platform }}
22+
- ${{ compiler('c') }}
23+
- pip
24+
- m4
25+
- make
26+
host:
27+
- python
28+
- libxml2
29+
- hdf5
30+
- zlib
31+
run:
32+
- python
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# remove the emcc symlink in the $BUILD_PREFIX/bin
4+
rm $BUILD_PREFIX/bin/emcc
5+
6+
# make callable
7+
chmod +x $RECIPE_DIR/emcc_wrapper.sh
8+
9+
# create symlink to $RECIPE_DIR/emcc_wrapper.sh
10+
ln -s $RECIPE_DIR/emcc_wrapper.sh $BUILD_PREFIX/bin/emcc
11+
12+
${PYTHON} -m pip install .
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -e
3+
4+
$BUILD_PREFIX/bin/python3 $RECIPE_DIR/py_emcc_wrapper.py $BUILD_PREFIX/opt/emsdk/upstream/emscripten/emcc "$@"
5+
exit $?
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sys
2+
import subprocess
3+
if __name__ == '__main__':
4+
5+
args = sys.argv[2:]
6+
7+
filtered_args = []
8+
for arg in args:
9+
if ("-Wl,-R$PREFIX/lib" in arg )or ("-R" in arg):
10+
print("removed arg:", arg)
11+
else:
12+
filtered_args.append(arg)
13+
14+
# run the actual command in argv[1]
15+
subprocess.run([sys.argv[1]] + filtered_args, check=True)
16+
17+
18+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
context:
2+
version: "1.7.2"
3+
name: "netcdf4"
4+
5+
package:
6+
name: ${{ name }}
7+
version: ${{ version }}
8+
9+
source:
10+
url: https://github.com/Unidata/netcdf4-python/archive/refs/tags/v${{ version }}rel.tar.gz
11+
sha256: cce7d42a83f84b6ce6288bb2fb171d5ffd294f1a1ba2650807d238ae961e9629
12+
build:
13+
number: 0
14+
15+
requirements:
16+
build:
17+
- python
18+
- cross-python_${{ target_platform }}
19+
- ${{ compiler("c") }}
20+
- pip
21+
- pkg-config
22+
- numpy
23+
- cython
24+
host:
25+
- python
26+
- hdf5
27+
- libnetcdf
28+
run:
29+
- python
30+
- numpy
31+
- hdf5
32+
- cftime
33+
- certifi
34+
35+
tests:
36+
- script: pytester
37+
requirements:
38+
build:
39+
- pytester
40+
run:
41+
- pytester-run
42+
files:
43+
recipe:
44+
- test_netcdf4.py
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def test_netcdf4():
2+
from netCDF4 import Dataset
3+
rootgrp = Dataset("test.nc", "w", format="NETCDF4")
4+
rootgrp.data_model == "NETCDF4"
5+
rootgrp.close()
6+
7+

variant.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ libmatio:
443443
libmicrohttpd:
444444
- 0.9
445445
libnetcdf:
446-
- 4.8.1
446+
- 4.9.3
447447
libopencv:
448448
- 4.5.5
449449
libpcap:

0 commit comments

Comments
 (0)