It is not currently possible to select a specific python version. If python-2.3 and python-2.4 are installed, you get python-2.4. This patch adds comparisons operators in a backward compatible way that allows to say : "I want python-2.3 and nothing else".
The work is not significant (lacks originality) and I am not allowed to claim copyright on it. Therefore there is no point in signing a copyright assignment. The GPL compliance lab of the FSF can confirm this if needed. The description of the new feature: .m4/python.m4: When using AM_PATH_PYTHON macro you can now specify a VERSION-CONSTRAINT. If the VERSION-CONSTRAINT argument is passed, AM_PATH_PYTHON will cause an error if the version of python installed on the system doesn't meet the requirement. VERSION-CONSTRAINT should consist of an operator (>=, <=, =, >, <) followed by a version (1, 2, 2.3, 2.4, 1.5.2 etc.) Examples: >2.3, =2.2, >=1.5.1 ... If the operator is omitted, it defaults to >= (i.e. 2.3 is equivalent to >=2.3) The Changelog entry: 2005-09-30 Ludovic Heyberger <[EMAIL PROTECTED]> * m4/python.m4 (AM_PATH_PYTHON): Added python version constraint The NEWS entry: - AM_PATH_PYTHON now supports a VERSION-CONSTRAINT argument. =2.3 will find python2.3 even if python2.4 is available. It is backward compatible, 2.3 is understood as >=2.3. Attached in this mail, you will find: - python.m4.patch (./m4/python.m4) - automake.texi.patch (./doc/automake.texi) - python13.test (./tests/python13.test) - python14.test (./tests/python14.test) Just let me know if you need explanations about details of this patch. The patches and tests are against the CVS tree of 2005 Sep 30.
--- python.m4 2005-09-16 12:34:39.000000000 +0200 +++ python.m4.patched 2005-09-30 15:27:52.475685168 +0200 @@ -2,6 +2,7 @@ ## Python file handling ## From Andrew Dalke ## Updated by James Henstridge +## Updated by Ludovic Heyberger, Loic Dachary (2005) ## ------------------------ # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. @@ -10,7 +11,7 @@ # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# AM_PATH_PYTHON([VERSION-CONSTRAINT], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # --------------------------------------------------------------------------- # Adds support for distributing Python modules and packages. To # install modules, copy them to $(pythondir), using the python_PYTHON @@ -28,10 +29,12 @@ # environment variable, or create a .pth file (see the python # documentation for details). # -# If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will +# If the VERSION-CONSTRAINT argument is passed, AM_PATH_PYTHON will # cause an error if the version of python installed on the system -# doesn't meet the requirement. MINIMUM-VERSION should consist of -# numbers and dots only. +# doesn't meet the requirement. VERSION-CONSTRAINT should consist of +# an operator (>=, <=, =, >, <) followed by a version (1, 2, 2.3, 2.4, 1.5.2 etc.) +# Examples: >2.3, =2.2, >=1.5.1 ... If the operator is omitted, it defaults +# to >= (i.e. 2.3 is equivalent to >=2.3) AC_DEFUN([AM_PATH_PYTHON], [ dnl Find a Python interpreter. Python versions prior to 1.5 are not @@ -50,22 +53,29 @@ fi am_display_PYTHON=python ], [ + if expr "$1" : "[[<>=]]" > /dev/null ; then + required_version="$1" + elif test -z "$1" || expr "$1" : '[ ]*$' > /dev/null ; then + required_version="" + else + required_version=">=$1" + fi dnl A version check is needed. if test -n "$PYTHON"; then # If the user set $PYTHON, use it and don't search something else. - AC_MSG_CHECKING([whether $PYTHON version >= $1]) - AM_PYTHON_CHECK_VERSION([$PYTHON], [$1], + AC_MSG_CHECKING([whether $PYTHON version $required_version]) + AM_PYTHON_CHECK_VERSION([$PYTHON], [$required_version], [AC_MSG_RESULT(yes)], [AC_MSG_ERROR(too old)]) am_display_PYTHON=$PYTHON else # Otherwise, try each interpreter until we find one that satisfies # VERSION. - AC_CACHE_CHECK([for a Python interpreter with version >= $1], + AC_CACHE_CHECK([for a Python interpreter with version $required_version], [am_cv_pathless_PYTHON],[ for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do test "$am_cv_pathless_PYTHON" = none && break - AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break]) + AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$required_version], [break]) done]) # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. if test "$am_cv_pathless_PYTHON" = none; then @@ -149,20 +159,51 @@ ]) -# AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +# AM_PYTHON_CHECK_VERSION(PROG, VERSION-CONSTRAINT, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # --------------------------------------------------------------------------- -# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION. +# Run ACTION-IF-TRUE if the Python interpreter PROG has version that +# satifies VERSION-CONSTRAINT. # Run ACTION-IF-FALSE otherwise. # This test uses sys.hexversion instead of the string equivalent (first # word of sys.version), in order to cope with versions such as 2.2c1. # hexversion has been introduced in Python 1.5.2; it's probably not # worth to support older versions (1.5.1 was released on October 31, 1998). +# Do *not* use the operator as it is not available in every supported +# python versions AC_DEFUN([AM_PYTHON_CHECK_VERSION], [prog="import sys, string -# split strings by '.' and convert to numeric. Append some zeros -# because we need at least 4 digits for the hex conversion. -minver = map(int, string.split('$2', '.')) + [[0, 0, 0]] -minverhex = 0 -for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[[i]] -sys.exit(sys.hexversion < minverhex)" +if '$2' == '': sys.exit(0) +spec = string.replace('$2', ' ', '') +if spec[[:2]] == '<=': + version_string = spec[[2:]] +elif spec[[:2]] == '>=': + version_string = spec[[2:]] +elif spec[[:1]] == '=': + version_string = spec[[1:]] +elif spec[[:1]] == '>': + version_string = spec[[1:]] +elif spec[[:1]] == '<': + version_string = spec[[1:]] +ver = map(int, string.split(version_string, '.')) +syshexversion = sys.hexversion >> (8 * (4 - l""en(ver))) +verhex = 0 +for i in xrange(0, l""en(ver)): verhex = (verhex << 8) + ver[[i]] +print 'sys.hexversion = 0x%08x, verhex = 0x%08x' % (syshexversion, verhex) +if spec[[:2]] == '<=': + status = syshexversion <= verhex +elif spec[[:2]] == '>=': + status = syshexversion >= verhex +elif spec[[:1]] == '=': + status = syshexversion == verhex +elif spec[[:1]] == '>': + status = syshexversion > verhex +elif spec[[:1]] == '<': + status = syshexversion < verhex +else: + status = syshexversion >= verhex + +if status: + sys.exit(0) +else: + sys.exit(1)" AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
--- automake.texi 2005-09-16 16:23:46.000000000 +0200 +++ automake.texi.patched 2005-09-30 15:23:53.129071384 +0200 @@ -5815,15 +5815,55 @@ @code{pyexecdir_PYTHON}, @code{pkgpyexecdir_PYTHON}, depending where you want your files installed. [EMAIL PROTECTED] AM_PATH_PYTHON ([EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]) [EMAIL PROTECTED] AM_PATH_PYTHON ([EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]) -Search a Python interpreter on the system. This macro takes three -optional arguments. The first argument, if present, is the minimum -version of Python required for this package: @code{AM_PATH_PYTHON} -will skip any Python interpreter that is older than @var{VERSION}. -If an interpreter is found and satisfies @var{VERSION}, then [EMAIL PROTECTED] is run. Otherwise, @var{ACTION-IF-NOT-FOUND} is -run. +Search a Python interpreter on the system. + [EMAIL PROTECTED] will try the following interpreter command +names: @command{python} @command{python2} @command{python2.5} [EMAIL PROTECTED] @command{python2.3} @command{python2.2} [EMAIL PROTECTED] @command{python2.0} @command{python1.6} [EMAIL PROTECTED] If no @var{VERSION-CONSTRAINT} argument is +provided, the first interpreter found is selected. The order matters : [EMAIL PROTECTED] has precedence over @command{python2.2} and [EMAIL PROTECTED] has precedence over @command{python2.4}, even if [EMAIL PROTECTED] happens to be a 1.5.2 interpreter. + +This macro takes three optional arguments. + +The first argument is a version number (i.e. 2.3, 2.4, 1.5.2, etc.): [EMAIL PROTECTED] will skip any Python interpreter that is older +than @var{VERSION-CONSTRAINT}. If it starts with a comparison +operator (<, >, >=, <=, =), the first Python interpreter matching the +constraint will be selected. + +For instance, if @command{python2.2}, @command{python2.3} and [EMAIL PROTECTED] are installed: + [EMAIL PROTECTED] @code [EMAIL PROTECTED] =2.3 +will select @command{python2.3} + [EMAIL PROTECTED] <2.3 +will select @command{python2.2} + [EMAIL PROTECTED] >2.3 +will select @command{python2.4} + [EMAIL PROTECTED] <=2.3 +will select @command{python2.3} + [EMAIL PROTECTED] >=2.3 +will select @command{python2.4} [EMAIL PROTECTED] vtable + +When the comparison operator is omitted, it defaults to >= (hence 2.3 +is equivalent to >=2.3). White spaces in @var{VERSION-CONSTRAINT} +(space and tabulation) are ignored (i.e. = 2.3 is equivalent to =2.3). + +If an interpreter is found and satisfies @var{VERSION-CONSTRAINT}, +then @var{ACTION-IF-FOUND} is run. Otherwise, [EMAIL PROTECTED] is run. If @var{ACTION-IF-NOT-FOUND} is not specified, the default is to abort configure. This is fine when Python is an absolute requirement for the @@ -5901,6 +5941,12 @@ Variables, autoconf, The Autoconf Manual}). See also @ref{Hard-Coded Install Paths}. [EMAIL PROTECTED] does not support Python versions older than +1.5.2. It will look for Python interpreters under the following +names: @command{python} @command{python2} @command{python2.5} [EMAIL PROTECTED] @command{python2.3} @command{python2.2} [EMAIL PROTECTED] @command{python2.0} @command{python1.6} [EMAIL PROTECTED] @node Documentation @chapter Building documentation
python13.test
Description: Binary data
python14.test
Description: Binary data