BuildSystem: Search for Python/C API when possibly needed only.

The Python/C API is used only if the Test Framework was enabled in Asterisk
'make menuselect'. The Test Framework is available only if the Developer Mode
was enabled in Asterisk './configure --enable-dev-mode'. And that Python/C API
is used only if the PJProject was found and not disabled in Asterisk; the user
did not go for './configure --without-pjproject'.

Furthermore, because version 2 of that Python/C API is required (currently) and
because some platforms do not offer a generic version 2, the script searches
for 2.7 explicitly as well.

To avoid version mismatch between the Python/C API and the Python environment,
the script searches for the latter in the same versions, in the same the order
as well. Because this Python/C API is just for (some) Asterisk contributors,
the script also goes for the Python 3 environment as a last resort for all
other Asterisk users. This allows 'make full' even on minimal installations of
Ubuntu 18.04 LTS and newer.

Because the Python/C API is Asterisk contributor specific, the Python packages
are removed from the script './contrib/scripts/install_prereq' as this script
is intended for Asterisk users. Asterisk contributors have to install much more
packages in any case, like:
sudo apt install autoconf automake git git-review python2.7-dev

ASTERISK-28824
ASTERISK-27717

Change-Id: Id46d357e18869f64dcc217b8fdba821b63eeb876
This commit is contained in:
Alexander Traud
2020-04-12 16:53:50 +02:00
committed by Friendly Automation
parent 9e0995b1b7
commit dfdff0f9ec
3 changed files with 222 additions and 17 deletions

View File

@@ -263,7 +263,7 @@ AC_PATH_PROG([CAT], [cat], :)
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.7 python2 python python3], :)
AC_PATH_PROG([FIND], [find], :)
AC_PATH_PROG([BASENAME], [basename], :)
AC_PATH_PROG([DIRNAME], [dirname], :)
@@ -2458,11 +2458,24 @@ if test "$USE_PJPROJECT" != "no" ; then
AST_EXT_LIB_CHECK([PJSIP_AUTH_CLT_DEINIT], [pjsip], [pjsip_auth_clt_deinit], [pjsip.h], [$PJPROJECT_LIB], [$PJPROJECT_CFLAGS])
AST_EXT_LIB_CHECK([PJSIP_TSX_LAYER_FIND_TSX2], [pjsip], [pjsip_tsx_layer_find_tsx2], [pjsip.h], [$PJPROJECT_LIB], [$PJPROJECT_CFLAGS])
fi
fi
AC_SUBST([PYTHONDEV_LIB])
AC_SUBST([PYTHONDEV_INCLUDE])
AST_PKG_CONFIG_CHECK([PYTHONDEV], [python])
if test "x$PBX_PJPROJECT" = "x1" ; then
if test "x${AST_DEVMODE}" = "xyes" ; then
AC_SUBST([PYTHONDEV_LIB])
AC_SUBST([PYTHONDEV_INCLUDE])
AST_PKG_CONFIG_CHECK([PYTHONDEV], [python-2.7])
AST_PKG_CONFIG_CHECK([PYTHONDEV], [python2])
AST_PKG_CONFIG_CHECK([PYTHONDEV], [python])
# The PJProject offers a C extension to Python. That wrapper is used by the
# Asterisk Test Framework, which requires Asterisk to be in Developer Mode.
# However, the used wrapper (called 'PJSUA Python') is deprecated and was not
# ported from Python 2.7 to Python 3.x. This is confirmed; it simply does not
# build. For more see <http://www.pjsip.org/trac/wiki/Python_SIP_Tutorial>.
# Therefore, the C libraries for Python 3 are of no help in Asterisk:
#AST_PKG_CONFIG_CHECK([PYTHONDEV], [python3])
fi
fi
fi
AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])