diff options
-rw-r--r-- | m4/python.m4 | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/m4/python.m4 b/m4/python.m4 index e4d804d..bdc8ee6 100644 --- a/m4/python.m4 +++ b/m4/python.m4 @@ -74,8 +74,14 @@ CPPFLAGS="$save_CPPFLAGS" # and with python 3.0 support. AC_DEFUN([JD_PYTHON_CHECK_VERSION], [prog="import sys -minver = tuple(map(int, '$2'.split('.'))) -sys.exit(sys.version_info[[:3]] < minver)" +# split strings by '.' and convert to numeric. Append some zeros +# because we need at least 4 digits for the hex conversion. +# map returns an iterator in Python 3.0 and a list in 2.x +minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]] +minverhex = 0 +# xrange is not present in Python 3.0 and range returns an iterator +for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]] +sys.exit(sys.hexversion < minverhex)" AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 |