You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pygmt.show_versions doesn't show GDAL version #4102
Currently, we use the importlib library to obtain the GDAL version, but this only works when the GDAL Python bindings are installed.
Six months ago, we updated GMT's dependency from gdal to libgdal-core (see conda-forge/gmt-feedstock@48fb3f0), so now only the GDAL C library is included, without the Python bindings. This explains why importlib fails.
Potential solutions:
Use subprocess to call gdalinfo --version and parse the output
Use ctypes to obtain the GDAL version directly from the C library
No longer query the GDAL version
I have no strong preferences. Which one do you prefer? Or do you have a better solution?
We could probably do a similar try-except. Try to parse the GDAL version from rasterio/rioxarray (if installed), otherwise fallback to using a subprocess call? Ideally we could get it from GMT somehow if there is a C API that exposes it.
Activity
weiji14 commentedon Sep 19, 2025
For reference,
rioxarray.show_versionsgets its GDAL version using this chunk of code - https://github.com/corteva/rioxarray/blob/5cc63a7dc66535d427ec510da695eace48e5b840/rioxarray/_show_versions.py#L38-L52We could probably do a similar try-except. Try to parse the GDAL version from rasterio/rioxarray (if installed), otherwise fallback to using a subprocess call? Ideally we could get it from GMT somehow if there is a C API that exposes it.
seisman commentedon Sep 19, 2025
In #4104, ctypes is used to get the GDAL version from the GDAL C library.