[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
python-version.patch take 2
From: |
Alexandre Duret-Lutz |
Subject: |
python-version.patch take 2 |
Date: |
07 Dec 2001 17:39:02 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1 |
>>> "Akim" == Akim Demaille <address@hidden> writes:
[...]
Akim> If I were you, I would fetch it from Autoconf, and paste
Akim> it into Automake as AM_EVAL_LOG or something. Try to
Akim> remain independent until Autoconf made up its mind.
Ok. Here is my second proposal. I've also wrapped three of the
checks into AC_CACHE_CHECK, and added the missing AM_PATH_PROG call
Patrick complained about.
Index: ChangeLog
from Alexandre Duret-Lutz <address@hidden>
* m4/python.m4 (AM_PATH_PYTHON): Check all known Python interpreters
in loop until we find one the satisfies the user supplied version.
Add python2 to the list of known interpreters. Don't use
changequote. Cache the calculation of PYTHON_VERSION and
PYTHON_PLATFORM.
(AM_PYTHON_CHECK_VERSION): New function, extracted from
AM_PATH_PYTHON and modernized.
* m4/runlog.m4: New file.
* m4/Makefile.am (m4data_DATA): Add it.
Index: m4/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/m4/Makefile.am,v
retrieving revision 1.37
diff -u -r1.37 Makefile.am
*** m4/Makefile.am 2001/10/20 11:14:37 1.37
--- m4/Makefile.am 2001/12/07 16:33:00
***************
*** 24,30 ****
m4data_DATA = as.m4 auxdir.m4 ccstdc.m4 cond.m4 depend.m4 depout.m4 \
dmalloc.m4 gcj.m4 header.m4 init.m4 install-sh.m4 lex.m4 \
lispdir.m4 make.m4 maintainer.m4 minuso.m4 missing.m4 multi.m4 \
! protos.m4 python.m4 regex.m4 sanity.m4 strip.m4 \
termios.m4 winsz.m4
EXTRA_DIST = $(m4data_DATA)
--- 24,30 ----
m4data_DATA = as.m4 auxdir.m4 ccstdc.m4 cond.m4 depend.m4 depout.m4 \
dmalloc.m4 gcj.m4 header.m4 init.m4 install-sh.m4 lex.m4 \
lispdir.m4 make.m4 maintainer.m4 minuso.m4 missing.m4 multi.m4 \
! protos.m4 python.m4 regex.m4 runlog.m4 sanity.m4 strip.m4 \
termios.m4 winsz.m4
EXTRA_DIST = $(m4data_DATA)
Index: m4/python.m4
===================================================================
RCS file: /cvs/automake/automake/m4/python.m4,v
retrieving revision 1.5
diff -u -r1.5 python.m4
*** m4/python.m4 2001/09/22 16:05:36 1.5
--- m4/python.m4 2001/12/07 16:33:00
***************
*** 44,112 ****
# doesn't meet the requirement. MINIMUM-VERSION should consist of
# numbers and dots only.
-
AC_DEFUN([AM_PATH_PYTHON],
[
! dnl Find a version of Python. I could check for python versions 1.4
! dnl or earlier, but the default installation locations changed from
dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
! dnl in 1.5, and I don't want to maintain that logic.
!
! AC_PATH_PROG(PYTHON, python python2.1 python2.0 python1.6 python1.5)
!
! dnl should we do the version check?
! ifelse([$1],[],,[
! AC_MSG_CHECKING(if Python version >= $1)
! changequote(<<, >>)dnl
! prog="
! import sys, string
! minver = '$1'
! pyver = string.split(sys.version)[0] # first word is version string
! # split strings by '.' and convert to numeric
! minver = map(string.atoi, string.split(minver, '.'))
! pyver = map(string.atoi, string.split(pyver, '.'))
! # we can now do comparisons on the two lists:
! if pyver >= minver:
! sys.exit(0)
! else:
! sys.exit(1)"
! changequote([, ])dnl
! if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
! then
! AC_MSG_RESULT(okay)
else
! AC_MSG_ERROR(too old)
fi
])
- AC_MSG_CHECKING([local Python configuration])
-
dnl Query Python for its version number. Getting [:3] seems to be
dnl the best way to do this; it's what "site.py" does in the standard
! dnl library. Need to change quote character because of [:3]
!
! AC_SUBST(PYTHON_VERSION)
! changequote(<<, >>)dnl
! PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"`
! changequote([, ])dnl
dnl Use the values of $prefix and $exec_prefix for the corresponding
dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
dnl distinct variables so they can be overridden if need be. However,
dnl general consensus is that you shouldn't need this ability.
! AC_SUBST(PYTHON_PREFIX)
! PYTHON_PREFIX='${prefix}'
- AC_SUBST(PYTHON_EXEC_PREFIX)
- PYTHON_EXEC_PREFIX='${exec_prefix}'
-
dnl At times (like when building shared libraries) you may want
dnl to know which OS platform Python thinks this is.
! AC_SUBST(PYTHON_PLATFORM)
! PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
dnl Set up 4 directories:
--- 44,108 ----
# doesn't meet the requirement. MINIMUM-VERSION should consist of
# numbers and dots only.
AC_DEFUN([AM_PATH_PYTHON],
[
! dnl Find a Python interpreter. Python versions prior to 1.5 are not
! dnl supported because the default installation locations changed from
dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
! dnl in 1.5.
! m4_define([_AM_PYTHON_INTERPRETER_LIST],
! [python python2 python2.1 python2.0 python1.6 python1.5])
!
! m4_if([$1],[],[
! dnl No version check is needed.
! # Find any Python interpreter.
! AC_PATH_PROG([PYTHON], _AM_PYTHON_INTERPRETER_LIST)],[
! 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_RESULT(yes)],
! [AC_MSG_ERROR(too old)])
else
! # Otherwise, try each interpreter until we find one that satisfies
! # VERSION.
! AC_CACHE_CHECK([for a Python interpreter with version >= $1],
! [am_cv_pathless_PYTHON],[
! for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST : ; do
! if test "$am_cv_pathless_PYTHON" = : ; then
! AC_MSG_ERROR([no suitable Python interpreter found])
! fi
! AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
! done])
! # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
! AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
fi
])
dnl Query Python for its version number. Getting [:3] seems to be
dnl the best way to do this; it's what "site.py" does in the standard
! dnl library.
+ AC_CACHE_CHECK([for $am_cv_pathless_PYTHON version], [am_cv_python_version],
+ [am_cv_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`])
+ AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
dnl Use the values of $prefix and $exec_prefix for the corresponding
dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
dnl distinct variables so they can be overridden if need be. However,
dnl general consensus is that you shouldn't need this ability.
! AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
! AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
dnl At times (like when building shared libraries) you may want
dnl to know which OS platform Python thinks this is.
! AC_CACHE_CHECK([for $am_cv_pathless_PYTHON platform],
! [am_cv_python_platform],
! [am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`])
! AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
dnl Set up 4 directories:
***************
*** 119,146 ****
dnl Also, if the package prefix isn't the same as python's prefix,
dnl then the old $(pythondir) was pretty useless.
! AC_SUBST(pythondir)
! pythondir=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
dnl more consistent with the rest of automake.
dnl Maybe this should be put in python.am?
! AC_SUBST(pkgpythondir)
! pkgpythondir=\${pythondir}/$PACKAGE
dnl pyexecdir -- directory for installing python extension modules
dnl (shared libraries) Was PYTHON_SITE_EXEC in previous betas.
! AC_SUBST(pyexecdir)
! pyexecdir=$PYTHON_EXEC_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
dnl Maybe this should be put in python.am?
-
- AC_SUBST(pkgpyexecdir)
- pkgpyexecdir=\${pyexecdir}/$PACKAGE
! AC_MSG_RESULT([looks good])
])
--- 115,153 ----
dnl Also, if the package prefix isn't the same as python's prefix,
dnl then the old $(pythondir) was pretty useless.
! AC_SUBST([pythondir],
! [$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages])
dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
dnl more consistent with the rest of automake.
dnl Maybe this should be put in python.am?
! AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
dnl pyexecdir -- directory for installing python extension modules
dnl (shared libraries) Was PYTHON_SITE_EXEC in previous betas.
! AC_SUBST([pyexecdir],
! [${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages])
dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
dnl Maybe this should be put in python.am?
! AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
])
+
+
+ # AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+ # ---------------------------------------------------------------------------
+ # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
+ # Run ACTION-IF-FALSE otherwise.
+ AC_DEFUN([AM_PYTHON_CHECK_VERSION],
+ [prog="import sys, string
+ pyver = string.split(sys.version)[[0]] # first word is version string
+ # split strings by '.' and convert to numeric
+ minver = map(string.atoi, string.split('$2', '.'))
+ pyver = map(string.atoi, string.split(pyver, '.'))
+ # we can now do comparisons on the two lists:
+ sys.exit(pyver < minver)"
+ AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
Index: m4/runlog.m4
===================================================================
RCS file: runlog.m4
diff -N runlog.m4
*** /dev/null Tue May 5 13:32:27 1998
--- m4/runlog.m4 Fri Dec 7 08:33:00 2001
***************
*** 0,-1 ****
--- 1,27 ----
+ # Copyright 2001 Free Software Foundation, Inc. -*- Autoconf -*-
+
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2, or (at your option)
+ # any later version.
+
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ # 02111-1307, USA.
+
+ # AM_RUN_LOG(COMMAND)
+ # -------------------
+ # Run COMMAND, save the exit status in ac_status, and log it.
+ # (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
+ AC_DEFUN([AM_RUN_LOG],
+ [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
+ ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ (exit $ac_status); }])
--
Alexandre Duret-Lutz