From 1af81537db9cdc74fbad7ab4db30847bcdcb5dce Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Wed, 26 Nov 2025 18:05:29 +0000 Subject: [PATCH] Compatibility with NetCDF4 v1.7.3 . --- docs/src/whatsnew/3.14.rst | 9 +++++++-- lib/iris/loading.py | 4 +++- requirements/py311.yml | 2 +- requirements/py312.yml | 2 +- requirements/py313.yml | 2 +- requirements/pypi-core.txt | 2 +- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/src/whatsnew/3.14.rst b/docs/src/whatsnew/3.14.rst index 7822c900a9..39a0cc45bd 100644 --- a/docs/src/whatsnew/3.14.rst +++ b/docs/src/whatsnew/3.14.rst @@ -60,6 +60,8 @@ v3.14.1 (Date TBD) #. Fixed compatibility with NumPy v2 for :meth:`~iris.coords.Coord.guess_bounds` :ref:`See the full entry for more<3_14_1_guess_bounds>`. + #. Removed netCDF4<1.7.3 temporary pin. + ✨ Features =========== @@ -174,10 +176,13 @@ v3.14.1 (Date TBD) handles additional shapefile types and projections. (:issue:`6126`, :pull:`6129`) #. `@pp-mo`_ added a temporary dependency pins for Python<3.14, dask<2025.10.0 and - netCDF4<1.7.3. All of these introduce problems that won't necessarily be fixed soon, - so we anticipate that these pins will be wanted for the v3.14 release. + netCDF4<1.7.3. Edit 2025-11-25: the netCDF4 pin has now been removed in + :pull:`6826`. (:issue:`6775`, :issue:`6776`, :issue:`6777`, :pull:`6773`) +#. `@trexfeathers`_ fixed an incompatibility with the netCDF4 package (relating + to dataset iterability). (:issue:`6777`, :pull:`6826`) + 📚 Documentation ================ diff --git a/lib/iris/loading.py b/lib/iris/loading.py index febdeac714..5d65e2e290 100644 --- a/lib/iris/loading.py +++ b/lib/iris/loading.py @@ -66,10 +66,12 @@ def context(self, load_real=True): def _generate_cubes(uris, callback, constraints): + from netCDF4 import Dataset + import iris.io """Return a generator of cubes given the URIs and a callback.""" - if isinstance(uris, str) or not isinstance(uris, Iterable): + if isinstance(uris, (str, Dataset)) or not isinstance(uris, Iterable): # Make a string, or other single item, into an iterable. uris = [uris] diff --git a/requirements/py311.yml b/requirements/py311.yml index ce3ebebad4..57799f501a 100644 --- a/requirements/py311.yml +++ b/requirements/py311.yml @@ -17,7 +17,7 @@ dependencies: - dask-core >=2025.1.0,<2025.10.0 # https://github.com/SciTools/iris/issues/6776 - libnetcdf !=4.9.1 - matplotlib-base >=3.5, !=3.9.1 - - netcdf4<1.7.3 # https://github.com/SciTools/iris/issues/6777 + - netcdf4 - numpy >=1.24, !=1.24.3 - python-xxhash - pyproj diff --git a/requirements/py312.yml b/requirements/py312.yml index 81b2fe64bc..ca3838b93a 100644 --- a/requirements/py312.yml +++ b/requirements/py312.yml @@ -17,7 +17,7 @@ dependencies: - dask-core >=2025.1.0,<2025.10.0 # https://github.com/SciTools/iris/issues/6776 - libnetcdf !=4.9.1 - matplotlib-base >=3.5, !=3.9.1 - - netcdf4<1.7.3 # https://github.com/SciTools/iris/issues/6777 + - netcdf4 - numpy >=1.24, !=1.24.3 - python-xxhash - pyproj diff --git a/requirements/py313.yml b/requirements/py313.yml index d2a9603601..1708c462f0 100644 --- a/requirements/py313.yml +++ b/requirements/py313.yml @@ -17,7 +17,7 @@ dependencies: - dask-core >=2025.1.0,<2025.10.0 # https://github.com/SciTools/iris/issues/6776 - libnetcdf !=4.9.1 - matplotlib-base >=3.5, !=3.9.1 - - netcdf4<1.7.3 # https://github.com/SciTools/iris/issues/6777 + - netcdf4 - numpy >=1.24, !=1.24.3 - python-xxhash - pyproj diff --git a/requirements/pypi-core.txt b/requirements/pypi-core.txt index ceb22f336b..9399d228f1 100644 --- a/requirements/pypi-core.txt +++ b/requirements/pypi-core.txt @@ -4,7 +4,7 @@ cftime>=1.5.0 dask[array]>=2025.1.0,<2025.10.0 # https://github.com/SciTools/iris/issues/6776 # libnetcdf!=4.9.1 (not available on PyPI) matplotlib>=3.5 -netcdf4<1.7.3 # https://github.com/SciTools/iris/issues/6777 +netcdf4 numpy>=1.24,!=1.24.3 pyproj scipy