From 25e3acdee6790f93216c9cdb38043c25a1244721 Mon Sep 17 00:00:00 2001 From: "Sadie L. Bartholomew" Date: Fri, 4 Sep 2026 23:33:16 +0100 Subject: [PATCH 1/4] Add missing optional deps, pyproj & healpix, to env output --- cf/functions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cf/functions.py b/cf/functions.py index 04d7555438..2b3b566931 100644 --- a/cf/functions.py +++ b/cf/functions.py @@ -3,6 +3,7 @@ import warnings from collections.abc import Iterable from functools import lru_cache, partial +from importlib.metadata import version from importlib.util import find_spec from itertools import product from os import mkdir @@ -3123,6 +3124,11 @@ def environment(display=True, paths=True): "cartopy": _get_module_info("cartopy", try_except=True), "cfplot": _get_module_info("cfplot", try_except=True), "cf": (__version__, _os_path_abspath(__file__)), + # Healpix module doesn't define a __version__, so can't as standard use + # _get_module_info, but I have opened an Issue with them to define + # this (see: TODO) + "healpix": (version("healpix"), find_spec("healpix").origin), + "pyproj": _get_module_info("pyproj", try_except=True), } string = "{0}: {1!s}" if paths: From b08cab417756a3b60c06214735feceed1a2466f0 Mon Sep 17 00:00:00 2001 From: "Sadie L. Bartholomew" Date: Fri, 4 Sep 2026 23:37:32 +0100 Subject: [PATCH 2/4] Sort asciibetically output of cf.environment() --- cf/functions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cf/functions.py b/cf/functions.py index 2b3b566931..6a6db27269 100644 --- a/cf/functions.py +++ b/cf/functions.py @@ -3142,6 +3142,12 @@ def environment(display=True, paths=True): ] ) + # There are a lot of dependencies (compulsory + optional) to print so + # show them in asciibetical order, with the happy coincidence that the + # 'cf*' libraries, 'Platform' and 'Python' still come near the top (the + # (latter because of the capitalisation) so are easy to pick out. + out.sort() + if display: print("\n".join(out)) # pragma: no cover else: From 068c51bf3f7f8bc327429655f7895e74914f2383 Mon Sep 17 00:00:00 2001 From: "Sadie L. Bartholomew" Date: Fri, 4 Sep 2026 23:49:45 +0100 Subject: [PATCH 3/4] Update test_functions for cf.environment() new order & entries --- cf/test/test_functions.py | 47 +++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/cf/test/test_functions.py b/cf/test/test_functions.py index 23f0306ada..f65eba8819 100644 --- a/cf/test/test_functions.py +++ b/cf/test/test_functions.py @@ -302,36 +302,39 @@ def test_environment(self): # Expected full set of components expected = [ + "HDF5 library", "Platform", "Python", - "packaging", - "numpy", + "activestorage", + "cartopy", + "cf", + "cfdm", "cfdm.core", - "udunits2 library", - "HDF5 library", - "netcdf library", - "netCDF4", - "xnetcdf", - "h5netcdf", - "h5py", - "pyfive", - "zarr", - "fsspec", - "scipy", - "dask", - "distributed", + "cfplot", "cftime", "cfunits", - "cfdm", + "dask", + "distributed", "esmpy/ESMF", - "psutil", + "fsspec", + "h5netcdf", + "h5py", + "healpix", "matplotlib", - "activestorage", - "cartopy", - "cfplot", - "cf", - "xarray", + "netCDF4", + "netcdf library", + "numpy", + "packaging", + "psutil", + "pyfive", + "pyproj", + "scipy", + "udunits2 library", "umfive", + "uritools", + "xarray", + "xnetcdf", + "zarr", ] # Ensure all expected components are present From 250ca5b25149727aa51b64eb5586a9deb65387fb Mon Sep 17 00:00:00 2001 From: "Sadie L. Bartholomew" Date: Mon, 7 Sep 2026 16:52:18 +0100 Subject: [PATCH 4/4] Include link to Issue for tracking in cf.environment() comment --- cf/functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cf/functions.py b/cf/functions.py index 6a6db27269..1adff73ac2 100644 --- a/cf/functions.py +++ b/cf/functions.py @@ -3126,7 +3126,7 @@ def environment(display=True, paths=True): "cf": (__version__, _os_path_abspath(__file__)), # Healpix module doesn't define a __version__, so can't as standard use # _get_module_info, but I have opened an Issue with them to define - # this (see: TODO) + # this (see: https://github.com/ntessore/healpix/issues/108) "healpix": (version("healpix"), find_spec("healpix").origin), "pyproj": _get_module_info("pyproj", try_except=True), }