|
24 | 24 | strings_to_ctypes_array,
|
25 | 25 | vectors_to_arrays,
|
26 | 26 | )
|
27 |
| -from pygmt.clib.loading import load_libgmt |
| 27 | +from pygmt.clib.loading import get_gmt_version, load_libgmt |
28 | 28 | from pygmt.datatypes import _GMT_DATASET, _GMT_GRID, _GMT_IMAGE
|
29 |
| -from pygmt.exceptions import ( |
30 |
| - GMTCLibError, |
31 |
| - GMTCLibNoSessionError, |
32 |
| - GMTInvalidInput, |
33 |
| - GMTVersionError, |
34 |
| -) |
| 29 | +from pygmt.exceptions import GMTCLibError, GMTCLibNoSessionError, GMTInvalidInput |
35 | 30 | from pygmt.helpers import (
|
36 | 31 | _validate_data_input,
|
37 | 32 | data_kind,
|
|
97 | 92 |
|
98 | 93 | # Load the GMT library outside the Session class to avoid repeated loading.
|
99 | 94 | _libgmt = load_libgmt()
|
| 95 | +__gmt_version__ = get_gmt_version(_libgmt) |
100 | 96 |
|
101 | 97 |
|
102 | 98 | class Session:
|
@@ -154,9 +150,6 @@ class Session:
|
154 | 150 | -55 -47 -24 -10 190 981 1 1 8 14 1 1
|
155 | 151 | """
|
156 | 152 |
|
157 |
| - # The minimum supported GMT version. |
158 |
| - required_version = "6.3.0" |
159 |
| - |
160 | 153 | @property
|
161 | 154 | def session_pointer(self):
|
162 | 155 | """
|
@@ -211,27 +204,11 @@ def info(self):
|
211 | 204 |
|
212 | 205 | def __enter__(self):
|
213 | 206 | """
|
214 |
| - Create a GMT API session and check the libgmt version. |
| 207 | + Create a GMT API session. |
215 | 208 |
|
216 | 209 | Calls :meth:`pygmt.clib.Session.create`.
|
217 |
| -
|
218 |
| - Raises |
219 |
| - ------ |
220 |
| - GMTVersionError |
221 |
| - If the version reported by libgmt is less than |
222 |
| - ``Session.required_version``. Will destroy the session before |
223 |
| - raising the exception. |
224 | 210 | """
|
225 | 211 | self.create("pygmt-session")
|
226 |
| - # Need to store the version info because 'get_default' won't work after |
227 |
| - # the session is destroyed. |
228 |
| - version = self.info["version"] |
229 |
| - if Version(version) < Version(self.required_version): |
230 |
| - self.destroy() |
231 |
| - raise GMTVersionError( |
232 |
| - f"Using an incompatible GMT version {version}. " |
233 |
| - f"Must be equal or newer than {self.required_version}." |
234 |
| - ) |
235 | 212 | return self
|
236 | 213 |
|
237 | 214 | def __exit__(self, exc_type, exc_value, traceback):
|
|
0 commit comments