python: Correctly check for Python major/minor.
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 2 Nov 2011 18:18:14 +0000 (18:18 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 9 Nov 2011 22:05:20 +0000 (22:05 +0000)
The manual for sys.version warns that you should not parse the string,
which we were doing.  It would have failed on python "2.10" or
similar.

Do it correctly using the sys.version_info struct instead.
(cherry picked from commit 646142f5136da9cfe2b908703a822c53350f70e9)

configure.ac

index 37913a3..5ca2938 100644 (file)
@@ -713,7 +713,9 @@ AS_IF([test "x$enable_python" != "xno"],
            AC_MSG_RESULT([$PYTHON_PREFIX])
 
            AC_MSG_CHECKING([Python version])
-            PYTHON_VERSION=`$PYTHON -c "import sys; print (sys.version[[0:3]])"`
+            PYTHON_VERSION_MAJOR=`$PYTHON -c "import sys; print (sys.version_info.major)"`
+            PYTHON_VERSION_MINOR=`$PYTHON -c "import sys; print (sys.version_info.minor)"`
+            PYTHON_VERSION="$PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR"
            AC_MSG_RESULT([$PYTHON_VERSION])
 
             AC_MSG_CHECKING([for Python include path])