[gdal-dev] how to test for version number in python with gdal 1.10 ?

Etienne Tourigny etourigny.dev at gmail.com
Wed Jan 16 07:35:02 PST 2013


Hi,

Detection of gdal version in python using the following method fails
when using gdal-1.10 .

>>> print gdal.VersionInfo("RELEASE_NAME")
1.10dev
>>> print( gdal.VersionInfo("RELEASE_NAME") >= "1.7" )
False
>>> print( gdal.VersionInfo("RELEASE_NAME") >= "1.10" )
True


What is the recommended way to test for previous versions of gdal that
is backwards compatible and that support 1.10?

The following seems to work using VERSION_NUM:

in 1.10dev:
>>> gdal.VersionInfo("VERSION_NUM")
'1100000'
>>> print( int(gdal.VersionInfo("VERSION_NUM")) >= 1900 )
True
>>> print( int(gdal.VersionInfo("VERSION_NUM")) >= 1100000 )
True

and in 1.9.2:
>>> print( int(gdal.VersionInfo("VERSION_NUM")) >= 1900 )
True
>>> print( int(gdal.VersionInfo("VERSION_NUM")) >= 1100000 )
False


thanks,
Etienne


More information about the gdal-dev mailing list