Skip to content

Commit 6a6171e

Browse files
authored
Catch subprocess.CalledProcessError if 'gmt --show-library' fails (#974)
The `gmt --show-library` command may fail due to linking with a broken library. For example, if my netcdf library is missing, running `gmt --show-library` will raise: ``` dyld: Library not loaded: /usr/local/opt/netcdf/lib/libnetcdf.18.dylib Referenced from: /Users/seisman/opt/GMT-master/bin/gmt Reason: image not found [1] 84067 abort gmt ``` `subprocess.check_output` will raise the `CalledProcessError` exception. This PR catches the exception.
1 parent 30728fd commit 6a6171e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pygmt/clib/loading.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ def clib_full_names(env=None):
116116
)
117117
assert libfullpath.exists()
118118
yield str(libfullpath)
119-
except (FileNotFoundError, AssertionError): # command not found
119+
except (FileNotFoundError, AssertionError, sp.CalledProcessError):
120+
# the 'gmt' executable is not found
121+
# the gmt library is not found
122+
# the 'gmt' executable is broken
120123
pass
121124

122125
# 3. Search for DLLs in PATH by calling find_library() (Windows only)

0 commit comments

Comments
 (0)