Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CF writer crashing with netcdf development version #2961

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion satpy/tests/writer_tests/test_cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def test_no_warning_if_backends_match(self, scene, filename, monkeypatch):
import netCDF4
with monkeypatch.context() as m:
m.setattr(netCDF4, "__version__", "1.6.0")
m.setattr(netCDF4, "__netcdf4libversion__", "4.9.0")
m.setattr(netCDF4, "__netcdf4libversion__", "4.9.0-development")
m.setattr(xr, "__version__", "2022.12.0")
with warnings.catch_warnings():
scene.save_datasets(filename=filename, writer="cf")
Expand Down
5 changes: 4 additions & 1 deletion satpy/writers/cf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,11 @@ def _backend_versions_match():

def _get_backend_versions():
import netCDF4

# Make libnetcdf development version compatible with PEP440
libnetcdf_version = netCDF4.__netcdf4libversion__.replace("development", "dev")
sfinkens marked this conversation as resolved.
Show resolved Hide resolved
return {
"netCDF4": Version(netCDF4.__version__),
"libnetcdf": Version(netCDF4.__netcdf4libversion__),
"libnetcdf": Version(libnetcdf_version),
"xarray": Version(xr.__version__)
}
Loading