[Asterisk-code-review] BuildSystem: Go for Python 2 explicitly, because that is cur... (asterisk[master])
Alexander Traud
asteriskteam at digium.com
Tue Mar 27 06:44:13 CDT 2018
Alexander Traud has uploaded this change for review. ( https://gerrit.asterisk.org/8673
Change subject: BuildSystem: Go for Python 2 explicitly, because that is currently needed.
......................................................................
BuildSystem: Go for Python 2 explicitly, because that is currently needed.
Currently, Asterisk is not compatible with Python 3. Because of PEP 394, do not
go for the general 'python' but the specific 'python2'. This avoids build
failures with
make full
on platforms which use Python 3 as default already, like Arch Linux.
Furthermore, some platforms do not offer the shorthand 'python2', like NetBSD
and Gentoo Linux. For those platforms, Python must be called not only via its
major version but also via the minor version. In case of Python 2, this is easy,
because Python 2.7 was released already in mid-2010 and is going to be the last
minor version of that major version.
ASTERISK-27717
Change-Id: I29e694dc7e92510dc26b15895b55f78f67146b2c
---
M configure
M configure.ac
M contrib/scripts/install_prereq
3 files changed, 199 insertions(+), 16 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/73/8673/1
diff --git a/configure b/configure
index 9245063..e43961e 100755
--- a/configure
+++ b/configure
@@ -6820,8 +6820,10 @@
fi
-# Extract the first word of "python", so it can be a program name with args.
-set dummy python; ac_word=$2
+for ac_prog in python2 python2.7
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PYTHON+:} false; then :
@@ -6847,7 +6849,6 @@
done
IFS=$as_save_IFS
- test -z "$ac_cv_path_PYTHON" && ac_cv_path_PYTHON=":"
;;
esac
fi
@@ -6860,6 +6861,10 @@
$as_echo "no" >&6; }
fi
+
+ test -n "$PYTHON" && break
+done
+test -n "$PYTHON" || PYTHON=":"
# Extract the first word of "find", so it can be a program name with args.
set dummy find; ac_word=$2
@@ -26093,12 +26098,12 @@
pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python\""; } >&5
- ($PKG_CONFIG --exists --print-errors "python") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python < 3\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "python < 3") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python" 2>/dev/null`
+ pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python < 3" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@@ -26110,12 +26115,12 @@
pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python\""; } >&5
- ($PKG_CONFIG --exists --print-errors "python") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python < 3\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "python < 3") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python" 2>/dev/null`
+ pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python < 3" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@@ -26136,9 +26141,185 @@
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
- PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python" 2>&1`
+ PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python < 3" 2>&1`
else
- PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python" 2>&1`
+ PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python < 3" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$PYTHONDEV_PKG_ERRORS" >&5
+
+
+ PBX_PYTHONDEV=0
+
+
+elif test $pkg_failed = untried; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+ PBX_PYTHONDEV=0
+
+
+else
+ PYTHONDEV_CFLAGS=$pkg_cv_PYTHONDEV_CFLAGS
+ PYTHONDEV_LIBS=$pkg_cv_PYTHONDEV_LIBS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+ PBX_PYTHONDEV=1
+ PYTHONDEV_INCLUDE="$PYTHONDEV_CFLAGS"
+ PYTHONDEV_LIB="$PYTHONDEV_LIBS"
+
+$as_echo "#define HAVE_PYTHONDEV 1" >>confdefs.h
+
+
+fi
+ fi
+
+
+ if test "x${PBX_PYTHONDEV}" != "x1" -a "${USE_PYTHONDEV}" != "no"; then
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PYTHONDEV" >&5
+$as_echo_n "checking for PYTHONDEV... " >&6; }
+
+if test -n "$PYTHONDEV_CFLAGS"; then
+ pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python2\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "python2") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python2" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+if test -n "$PYTHONDEV_LIBS"; then
+ pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python2\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "python2") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python2" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python2" 2>&1`
+ else
+ PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python2" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$PYTHONDEV_PKG_ERRORS" >&5
+
+
+ PBX_PYTHONDEV=0
+
+
+elif test $pkg_failed = untried; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+ PBX_PYTHONDEV=0
+
+
+else
+ PYTHONDEV_CFLAGS=$pkg_cv_PYTHONDEV_CFLAGS
+ PYTHONDEV_LIBS=$pkg_cv_PYTHONDEV_LIBS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+ PBX_PYTHONDEV=1
+ PYTHONDEV_INCLUDE="$PYTHONDEV_CFLAGS"
+ PYTHONDEV_LIB="$PYTHONDEV_LIBS"
+
+$as_echo "#define HAVE_PYTHONDEV 1" >>confdefs.h
+
+
+fi
+ fi
+
+
+ if test "x${PBX_PYTHONDEV}" != "x1" -a "${USE_PYTHONDEV}" != "no"; then
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PYTHONDEV" >&5
+$as_echo_n "checking for PYTHONDEV... " >&6; }
+
+if test -n "$PYTHONDEV_CFLAGS"; then
+ pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python-2.7\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "python-2.7") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python-2.7" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+if test -n "$PYTHONDEV_LIBS"; then
+ pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python-2.7\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "python-2.7") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python-2.7" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python-2.7" 2>&1`
+ else
+ PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python-2.7" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$PYTHONDEV_PKG_ERRORS" >&5
diff --git a/configure.ac b/configure.ac
index 219f85d..dd5e08c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -261,7 +261,7 @@
AC_PATH_PROG([CUT], [cut], :)
AC_PATH_PROG([FLEX], [flex], :)
AC_PATH_PROG([GREP], [grep], :)
-AC_PATH_PROG([PYTHON], [python], :)
+AC_PATH_PROGS([PYTHON], [python2 python2.7], :)
AC_PATH_PROG([FIND], [find], :)
AC_PATH_PROG([COMPRESS], [compress], :)
AC_PATH_PROG([BASENAME], [basename], :)
@@ -2310,7 +2310,9 @@
AC_SUBST([PYTHONDEV_LIB])
AC_SUBST([PYTHONDEV_INCLUDE])
-AST_PKG_CONFIG_CHECK([PYTHONDEV], [python])
+AST_PKG_CONFIG_CHECK([PYTHONDEV], [python < 3])
+AST_PKG_CONFIG_CHECK([PYTHONDEV], [python2])
+AST_PKG_CONFIG_CHECK([PYTHONDEV], [python-2.7])
AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
diff --git a/contrib/scripts/install_prereq b/contrib/scripts/install_prereq
index 887c5e2..394e1e1 100755
--- a/contrib/scripts/install_prereq
+++ b/contrib/scripts/install_prereq
@@ -32,7 +32,7 @@
# Asterisk: for the unpackaged below:
PACKAGES_DEBIAN="$PACKAGES_DEBIAN wget subversion"
# Asterisk: for ./configure --with-pjproject-bundled:
-PACKAGES_DEBIAN="$PACKAGES_DEBIAN bzip2 patch python-dev"
+PACKAGES_DEBIAN="$PACKAGES_DEBIAN bzip2 patch python2.7-dev"
# Basic build system:
PACKAGES_RH="make gcc gcc-c++ pkgconfig"
@@ -48,7 +48,7 @@
# Asterisk: for the unpackaged below:
PACKAGES_RH="$PACKAGES_RH wget subversion"
# Asterisk: for ./configure --with-pjproject-bundled:
-PACKAGES_RH="$PACKAGES_RH bzip2 patch python-devel"
+PACKAGES_RH="$PACKAGES_RH bzip2 patch python2-devel"
# Basic build system:
PACKAGES_SUSE="make gcc gcc-c++ pkg-config"
@@ -128,7 +128,7 @@
# Asterisk: for the unpackaged below:
PACKAGES_FBSD="$PACKAGES_FBSD wget subversion"
# Asterisk: for ./configure --with-pjproject-bundled:
-PACKAGES_FBSD="$PACKAGES_FBSD bzip2 patch python"
+PACKAGES_FBSD="$PACKAGES_FBSD bzip2 patch python2"
KVERS=`uname -r`
--
To view, visit https://gerrit.asterisk.org/8673
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I29e694dc7e92510dc26b15895b55f78f67146b2c
Gerrit-Change-Number: 8673
Gerrit-PatchSet: 1
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180327/4ce761a8/attachment-0001.html>
More information about the asterisk-code-review
mailing list