Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cf/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: https://github.com/ntessore/healpix/issues/108)
"healpix": (version("healpix"), find_spec("healpix").origin),
"pyproj": _get_module_info("pyproj", try_except=True),
}
string = "{0}: {1!s}"
if paths:
Expand All @@ -3136,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:
Expand Down
47 changes: 25 additions & 22 deletions cf/test/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down