Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Dec 28, 2023
1 parent 38b9aca commit 1f3d922
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pygmt/clib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
tempfile_from_image,
)

__libgmt__ = load_libgmt()

FAMILIES = [
"GMT_IS_DATASET", # Entity is a data table
"GMT_IS_GRID", # Entity is a grid
Expand Down Expand Up @@ -89,6 +87,9 @@
np.datetime64: "GMT_DATETIME",
}

# load the GMT library outside of the Session class so it's loaded once.
_libgmt = load_libgmt()


class Session:
"""
Expand Down Expand Up @@ -310,7 +311,7 @@ def get_libgmt_func(self, name, argtypes=None, restype=None):
<class 'ctypes.CDLL.__init__.<locals>._FuncPtr'>
"""
if not hasattr(self, "_libgmt"):
self._libgmt = __libgmt__
self._libgmt = _libgmt
function = getattr(self._libgmt, name)
if argtypes is not None:
function.argtypes = argtypes
Expand Down

0 comments on commit 1f3d922

Please sign in to comment.