[asterisk-bugs] [JIRA] (ASTERISK-27717) [patch] BuildSystem: In NetBSD, the Python Programming Language is python-2.7.

Alexander Traud (JIRA) noreply at issues.asterisk.org
Tue Mar 27 05:15:39 CDT 2018


    [ https://issues.asterisk.org/jira/browse/ASTERISK-27717?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=242840#comment-242840 ] 

Alexander Traud edited comment on ASTERISK-27717 at 3/27/18 5:14 AM:
---------------------------------------------------------------------

After being accepted, the initial change got reverted because of three misunderstandings of mine:

1. The script configure looks for the Python runtime tool and Python shared libraries. The shared libraries are used only when the bundled PJProject is used, see {{PYTHONDEV_LIB}} in the file {{./third_party/pjproject/Makefile}}. Furthermore, the {{TEST_FRAMEWORK}} must be enabled in the Asterisk tool {{menuselect}}.

2. The {{TEST_FRAMEWORK}} is only available if the developer mode was activated via the script {{./configure}}. Consequently, the following steps are required in Ubuntu 16.04 LTS to reproduce the issue, which led to the revert of the change:{code}sudo apt install build-essential pkg-config autoconf automake
sudo apt install libedit-dev libjansson-dev libsqlite3-dev uuid-dev libxml2-dev
sudo apt install bzip2 patch python3-dev
wget downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar -zxf ./asterisk-*-current.tar.gz
cd ./asterisk-*
wget issues.asterisk.org/jira/secure/attachment/57262/NetBSD_enable_python_revision_2.patch
patch -p0 <./NetBSD_enable_python_revision_2.patch
./bootstrap.sh
./configure --with-pjproject-bundled --enable-dev-mode
make menuselect.makeopts
./menuselect/menuselect --enable TEST_FRAMEWORK
make full{code}

3. Scripts created for Python 2 are not always compatible with Python 3. In the Makefile, the detected Python runtime tool is used for the target {{doc/full-en_US.xml}} (which is accessible via {{make full}}) and the target {{ari-stubs}}. Both are not Python 3 compatible, yet (see [Gerrit 8646|http://gerrit.asterisk.org/8646]). Therefore, it was correct to use AC_PATH_PROG with _python2.7_ instead of the general _python_ (see [PEP 394|http://www.python.org/dev/peps/pep-0394/]). Since PJProject 2.7, Teluu [claims to be|http://trac.pjsip.org/repos/ticket/2034] compatible with Python 3 and use that on default. For example in Ubuntu 16.04 LTS, Teluu’s Python bindings for the PJSIP User Agent (PJSUA) are built by:
{code}sudo apt install build-essential bzip2 python3-dev swig
wget www.pjsip.org/release/latest/pjproject.tar.bz2
tar -jxf ./pjproject.tar.bz2
cd ./pjproject
CXXFLAGS='-std=c++03' ./configure --enabled-shared
make dep all
sudo make install
cd ./pjsip-apps/src/swig
make
sudo make install{code}SWIG is a tool, so the end-user is able to create the Python bindings himself, see their [current documentation|http://www.pjsip.org/docs/book-latest/html/intro_pjsua2.html#building-pjsua2]. The PJProject must be compiled with {{\-fPIC}} (thanks to [Luke Biddle|http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2017-November/040789.html]), therefore I went for {{\-\-enabled-shared}}. It is possible to edit (!) the Makefile, to use Python 2 instead of Python 3. Both variants of that binding work on the officially supported platforms by Asterisk.

However, that are the Python bindings for PJSUA2. Instead, Asterisk uses older Python bindings from Teluu, which are located in {{./pjsip-apps/src/python}}. Those bindings did not need SWIG. As of today, those bindings are Python 2 only, see their [current documentation…|http://trac.pjsip.org/repos/wiki/Python_SIP/Build_Install]

Until Asterisk is updated to use those newer bindings, Asterisk has to use Python 2 for the shared libraries and those bindings as well. Consequently in the script {{./configure}}, AST_PKG_CONFIG_CHECK must be called not with _python_ but _python-2.7_. Because the officially supported CentOS 6 only has Python 2.6, let us check for _python2_ as well.


was (Author: traud):
After being accepted, the initial change got reverted because of three misunderstandings of mine:

1. The script configure looks for the Python runtime tool and Python shared libraries. The shared libraries are used only when the bundled PJProject is used, see {{PYTHONDEV_LIB}} in the file {{./third_party/pjproject/Makefile}}. Furthermore, the {{TEST_FRAMEWORK}} must be enabled in the Asterisk tool {{menuselect}}.

2. The {{TEST_FRAMEWORK}} is only available if the developer mode was activated via the script {{./configure}}. Consequently, the following steps are required in Ubuntu 16.04 LTS to reproduce the issue, which led to the revert of the change:{code}sudo apt install build-essential pkg-config autoconf automake
sudo apt install libedit-dev libjansson-dev libsqlite3-dev uuid-dev libxml2-dev
sudo apt install bzip2 patch python3-dev
wget downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar -zxf ./asterisk-*-current.tar.gz
cd ./asterisk-*
wget NetBSD_enable_python_revision_2.patch
patch -p0 <./NetBSD_enable_python_revision_2.patch
./bootstrap.sh
./configure --with-pjproject-bundled --enable-dev-mode
make menuselect.makeopts
./menuselect/menuselect --enable TEST_FRAMEWORK
make full{code}

3. Scripts created for Python 2 are not always compatible with Python 3. In the Makefile, the detected Python runtime tool is used for the target {{doc/full-en_US.xml}} (which is accessible via {{make full}}) and the target {{ari-stubs}}. Both are not Python 3 compatible, yet (see [Gerrit 8646|http://gerrit.asterisk.org/8646]). Therefore, it was correct to use AC_PATH_PROG with _python2.7_ instead of the general _python_ (see [PEP 394|http://www.python.org/dev/peps/pep-0394/]). Since PJProject 2.7, Teluu [claims to be|http://trac.pjsip.org/repos/ticket/2034] compatible with Python 3 and use that on default. For example in Ubuntu 16.04 LTS, Teluu’s Python bindings for the PJSIP User Agent (PJSUA) are built by:
{code}sudo apt install build-essential bzip2 python3-dev swig
wget www.pjsip.org/release/latest/pjproject.tar.bz2
tar -jxf ./pjproject.tar.bz2
cd ./pjproject
CXXFLAGS='-std=c++03' ./configure --enabled-shared
make dep all
sudo make install
cd ./pjsip-apps/src/swig
make
sudo make install{code}SWIG is a tool, so the end-user is able to create the Python bindings himself, see their [current documentation|http://www.pjsip.org/docs/book-latest/html/intro_pjsua2.html#building-pjsua2]. The PJProject must be compiled with {{\-fPIC}} (thanks to [Luke Biddle|http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2017-November/040789.html]), therefore I went for {{\-\-enabled-shared}}. It is possible to edit (!) the Makefile, to use Python 2 instead of Python 3. Both variants of that binding work on the officially supported platforms by Asterisk.

However, that are the Python bindings for PJSUA2. Instead, Asterisk uses older Python bindings from Teluu, which are located in {{./pjsip-apps/src/python}}. Those bindings did not need SWIG. As of today, those bindings are Python 2 only, see their [current documentation…|http://trac.pjsip.org/repos/wiki/Python_SIP/Build_Install]

Until Asterisk is updated to use those newer bindings, Asterisk has to use Python 2 for the shared libraries and those bindings as well. Consequently in the script {{./configure}}, AST_PKG_CONFIG_CHECK must be called not with _python_ but _python-2.7_. Because the officially supported CentOS 6 only has Python 2.6, let us check for _python2_ as well.

> [patch] BuildSystem: In NetBSD, the Python Programming Language is python-2.7.
> ------------------------------------------------------------------------------
>
>                 Key: ASTERISK-27717
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-27717
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Core/BuildSystem
>    Affects Versions: 13.20.0, 15.3.0
>         Environment: NetBSD 7.1.1
>            Reporter: Alexander Traud
>            Assignee: Alexander Traud
>            Severity: Minor
>              Labels: patch, pjsip
>         Attachments: NetBSD_enable_python.patch, NetBSD_enable_python_revision_2.patch, NetBSD_enable_python_revision_3.patch
>
>
> The script {{./configure}} assumes that Python 2.x has a tool named 'python' and is listed in the tool {{pkg-config}} as 'python'. However, on some platforms, no default Python package exists. Python 2.x and Python 3.x can be installed side by side and each gets its own path/name. For example in NetBSD, the package python27 installs
> * {{/usr/pkg/bin/python2.7}} (without a dash) and
> * {{/usr/pkg/lib/pkgconf/python-2.7.pc}}.
> Therefore, Python could not be used by Asterisk in NetBSD.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list