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