Closed
Description
Description of the problem
In recent runs (https://github.com/GenericMappingTools/pygmt/actions/runs/560287188), test_load_libgmt_with_a_bad_library_path
fails with GMT dev on Linux and macOS, but pass on Windows, possibly because we merged #702. However, it passed when @weiji14 triggered the dev tests before merging (https://github.com/GenericMappingTools/pygmt/actions/runs/560286224).
It's unclear to me what happens. We can wait for today's scheduled runs and see if it works or not.
See the error messages below:
___________________ test_load_libgmt_with_a_bad_library_path ___________________
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f462205dca0>
def test_load_libgmt_with_a_bad_library_path(monkeypatch):
"""
Test that loading still works when given a bad library path.
"""
# Set a fake "GMT_LIBRARY_PATH"
monkeypatch.setenv("GMT_LIBRARY_PATH", "/not/a/real/path")
> assert check_libgmt(load_libgmt()) is None
/usr/share/miniconda3/envs/test/lib/python3.9/site-packages/pygmt/tests/test_clib_loading.py:48:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def load_libgmt():
"""
Find and load ``libgmt`` as a :py:class:`ctypes.CDLL`.
By default, will look for the shared library in the directory specified by
the environment variable ``GMT_LIBRARY_PATH``. If it's not set, will let
ctypes try to find the library.
Returns
-------
:py:class:`ctypes.CDLL` object
The loaded shared library.
Raises
------
GMTCLibNotFoundError
If there was any problem loading the library (couldn't find it or
couldn't access the functions).
"""
lib_fullnames = []
error = True
for libname in clib_full_names():
lib_fullnames.append(libname)
try:
libgmt = ctypes.CDLL(libname)
check_libgmt(libgmt)
error = False
break
except OSError as err:
error = err
if error:
> raise GMTCLibNotFoundError(
"Error loading the GMT shared library "
f"{', '.join(lib_fullnames)}.\n {error}."
)
E pygmt.exceptions.GMTCLibNotFoundError: Error loading the GMT shared library libgmt.so.
E libgmt.so: cannot open shared object file: No such file or directory.