aboutsummaryrefslogtreecommitdiffstats
path: root/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'common.py')
-rw-r--r--common.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/common.py b/common.py
index 247e733..78fa4fd 100644
--- a/common.py
+++ b/common.py
@@ -186,6 +186,21 @@ def format_time(s):
h, m = divmod(m, 60)
return f'{h:02d}:{m:02d}:{s + fs:06.3f}'
+# Return a boolean indicating whether the installer GDAL version is
+# greater than or equal to the provider (maj, min, rev) triplet.
+def gdal_version_min(maj=0, min=0, rev=0):
+ if maj < 1 or (maj == 1 and min < 10):
+ # GDAL_VERSION_NUM() macro was changed in 1.10. That version
+ # was released in 2013 so we blindly assume the installer
+ # version is more recent
+ return True
+
+ from osgeo import gdal
+ version_cur = int(gdal.VersionInfo());
+ # cf. GDAL_COMPUTE_VERSION(maj,min,rev) in gcore/gdal_version.h.in
+ version_min = maj*1000000 + min*10000 + rev*100
+ return version_min <= version_cur
+
######
# The function definitions below are taken from cpython's source code