[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PR/398: AM_PROG_PYTHON(VERSION, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
From: |
Alexandre Duret-Lutz |
Subject: |
PR/398: AM_PROG_PYTHON(VERSION, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) |
Date: |
Thu, 14 Aug 2003 01:12:42 +0200 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) |
PR/398 == it's not appropriate for all packages to abort when
Python is not found.
Here is my proposal to fix this: add support for ACTION-IF-FOUND
and ACTION-IF-NOT-FOUND arguments, as in many other Autoconf
macros. Note that the default is still to abort, for backward
compatibility.
2003-08-14 Alexandre Duret-Lutz <address@hidden>
Fix for PR automake/398:
* m4/python.m4: Do not call AC_PATH_PROGS if $PYTHON is already
set. Display `none' instead of `:' and $PYTHON is set to `:'
when no suitable interpreter is found. Honor ACTION-IF-FOUND and
ACTION-IF-NOT-FOUND.
* automake.texi (Python): Document ACTION-IF-FOUND and
ACTION-IF-NOT-FOUND.
* tests/python4.test, tests/python5.test, tests/python6.test,
tests/python7.test, tests/python8.test, tests/python9.test: New
files.
* tests/Makefile.am (TESTS): Add them.
Report from Per Cederqvist.
Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.221
diff -u -r1.221 NEWS
--- NEWS 27 Jul 2003 12:58:38 -0000 1.221
+++ NEWS 13 Aug 2003 23:06:52 -0000
@@ -79,6 +79,10 @@
links as part of the distclean target and including source files in
distributions.
+ - AM_PATH_PYTHON now support ACTION-IF-FOUND and ACTION-IF-NOT-FOUND
+ argument. The latter can be used to override the default behavior
+ (which is to abort).
+
* Obsolete features
- lisp_DATA is now allowed. If you are using the empty ELCFILES
Index: automake.texi
===================================================================
RCS file: /cvs/automake/automake/automake.texi,v
retrieving revision 1.348
diff -u -r1.348 automake.texi
--- automake.texi 31 Jul 2003 20:27:59 -0000 1.348
+++ automake.texi 13 Aug 2003 23:06:56 -0000
@@ -4392,17 +4392,45 @@
@samp{pyexecdir_PYTHON}, @samp{pkgpyexecdir_PYTHON}, depending where you
want your files installed.
address@hidden takes a single optional argument. This argument,
-if present, is the minimum version of Python which can be used for this
-package. If the version of Python found on the system is older than the
-required version, then @code{AM_PATH_PYTHON} will cause an error.
address@hidden(address@hidden, address@hidden,
address@hidden)} takes three optional arguments. It will
+search a Python interpreter on the system. The first argument, if
+present, is the minimum version of Python required for this package:
address@hidden will skip any Python interpreter which is older
+than @var{VERSION}. If an interpreter is found and satisfies
address@hidden, then @var{ACTION-IF-FOUND} is run. Otherwise,
address@hidden 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
+package. Therefore if Python >= 2.2 is only @emph{optional} to the
+package, @code{AM_PATH_PYTHON} could be called as follows.
+
address@hidden
+ AM_PATH_PYTHON(2.2,, :)
address@hidden example
@code{AM_PATH_PYTHON} creates several output variables based on the
Python installation found during configuration.
@vtable @code
@item PYTHON
-The name of the Python executable.
+The name of the Python executable, or @code{:} if no suitable
+interpreter could be found.
+
+Assuming @var{ACTION-IF-NOT-FOUND} is used (otherwise @file{./configure}
+will abort if Python is absent), the value of @code{PYTHON} can be used
+to setup a conditional in order to disable the relevant part of a build
+as follows.
+
address@hidden
+ AM_PATH_PYTHON(,, :)
+ AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
address@hidden example
+
+
+If the @var{ACTION-IF-NOT-FOUND}
+is specified
@item PYTHON_VERSION
The Python version number, in the form @address@hidden
Index: m4/python.m4
===================================================================
RCS file: /cvs/automake/automake/m4/python.m4,v
retrieving revision 1.13
diff -u -r1.13 python.m4
--- m4/python.m4 13 Aug 2003 21:29:58 -0000 1.13
+++ m4/python.m4 13 Aug 2003 23:06:56 -0000
@@ -21,7 +21,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
-# AM_PATH_PYTHON([MINIMUM-VERSION])
+# AM_PATH_PYTHON([MINIMUM-VERSION], [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
@@ -56,7 +56,10 @@
m4_if([$1],[],[
dnl No version check is needed.
# Find any Python interpreter.
- AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST)
+ if test -z "$PYTHON"; then
+ PYTHON=:
+ AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST)
+ fi
am_display_PYTHON=python
], [
dnl A version check is needed.
@@ -71,18 +74,25 @@
# 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
+ 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])
done])
# Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
- AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
+ if test "$am_cv_pathless_PYTHON" = none; then
+ PYTHON=:
+ else
+ AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
+ fi
am_display_PYTHON=$am_cv_pathless_PYTHON
fi
])
+ if test "$PYTHON" = :; then
+ dnl Run any user-specified action, or abort.
+ m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
+ else
+
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.
@@ -142,6 +152,11 @@
dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
+
+ dnl Run any user-specified action.
+ $2
+ fi
+
])
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.509
diff -u -r1.509 Makefile.am
--- tests/Makefile.am 9 Aug 2003 22:34:30 -0000 1.509
+++ tests/Makefile.am 13 Aug 2003 23:06:56 -0000
@@ -361,6 +361,12 @@
python.test \
python2.test \
python3.test \
+python4.test \
+python5.test \
+python6.test \
+python7.test \
+python8.test \
+python9.test \
recurs.test \
recurs2.test \
remake.test \
Index: tests/python4.test
===================================================================
RCS file: tests/python4.test
diff -N tests/python4.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/python4.test 13 Aug 2003 23:06:57 -0000
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2003 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 autoconf; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test detection of missing Python.
+
+# Python is not required for this test.
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<EOF
+AM_PATH_PYTHON
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Simulate no Python
+./configure PYTHON=: 2>stderr && exit 1
+cat stderr
+grep 'no suitable Python interpreter found' stderr
Index: tests/python5.test
===================================================================
RCS file: tests/python5.test
diff -N tests/python5.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/python5.test 13 Aug 2003 23:06:57 -0000
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2003 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 autoconf; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test detection of missing Python.
+# Same as python4.test, but requiring a version.
+
+# Python is not required for this test.
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<EOF
+# Hopefully the Python team will never release such a version.
+AM_PATH_PYTHON(9999.9)
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure 2>stderr && exit 1
+cat stderr
+grep 'no suitable Python interpreter found' stderr
Index: tests/python6.test
===================================================================
RCS file: tests/python6.test
diff -N tests/python6.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/python6.test 13 Aug 2003 23:06:57 -0000
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2003 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 autoconf; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test detection of missing Python.
+# Same as python4.test, but using a custom ACTION-IF-NOT-FOUND.
+
+# Python is not required for this test.
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<\EOF
+AM_PATH_PYTHON(,, [echo "GREP ME$PYTHON" >&2])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Simulate no Python
+./configure PYTHON=: 2>stderr
+cat stderr
+grep 'GREP ME:' stderr
Index: tests/python7.test
===================================================================
RCS file: tests/python7.test
diff -N tests/python7.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/python7.test 13 Aug 2003 23:06:57 -0000
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2003 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 autoconf; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test detection of missing Python.
+# Same as python6.test, but requiring a version.
+
+# Python is not required for this test.
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<\EOF
+# Hopefully the Python team will never release such a version.
+AM_PATH_PYTHON(9999.9,, [echo "GREP ME$PYTHON" >&2])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure 2>stderr
+cat stderr
+grep 'GREP ME:' stderr
Index: tests/python8.test
===================================================================
RCS file: tests/python8.test
diff -N tests/python8.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/python8.test 13 Aug 2003 23:06:57 -0000
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2003 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 autoconf; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test ACTION-IF-TRUE in AM_PATH_PYTHON.
+
+required=python
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<EOF
+AM_PATH_PYTHON(, [echo 'GREP ME' >&2])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure 2>stderr
+cat stderr
+grep 'GREP ME' stderr
Index: tests/python9.test
===================================================================
RCS file: tests/python9.test
diff -N tests/python9.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/python9.test 13 Aug 2003 23:06:57 -0000
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2003 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 autoconf; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test ACTION-IF-TRUE in AM_PATH_PYTHON.
+# Same as python8.test, but requiring a version.
+
+required=python
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<EOF
+AM_PATH_PYTHON(0.0, [echo 'GREP ME' >&2])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure 2>stderr
+cat stderr
+grep 'GREP ME' stderr
--
Alexandre Duret-Lutz
- PR/398: AM_PROG_PYTHON(VERSION, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND),
Alexandre Duret-Lutz <=