[asterisk-bugs] [JIRA] (ASTERISK-28824) BuildSystem: Search for Python/C API when possibly needed only.

Asterisk Team (JIRA) noreply at issues.asterisk.org
Wed Sep 9 11:10:46 CDT 2020


     [ https://issues.asterisk.org/jira/browse/ASTERISK-28824?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Asterisk Team updated ASTERISK-28824:
-------------------------------------

    Target Release Version/s: 18.0.0

> BuildSystem: Search for Python/C API when possibly needed only.
> ---------------------------------------------------------------
>
>                 Key: ASTERISK-28824
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-28824
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Core/BuildSystem
>    Affects Versions: 13.32.0, 16.9.0, 17.3.0
>            Reporter: Alexander Traud
>            Assignee: Alexander Traud
>            Severity: Minor
>              Labels: patch
>      Target Release: 13.33.0, 16.10.0, 17.4.0, 18.0.0
>
>         Attachments: python3.patch
>
>
> The script {{./contrib/scripts/install_prereq}} installs the package [python-dev|https://packages.ubuntu.com/eoan/python-dev] for Debian based Linux systems. However, Ubuntu 20.04 LTS (Focal) does not offer that package anymore. The script {{./configure}} requires the file {{python.pc}} when using the tool {{pkg-config}}. That file does not exist in Ubuntu anymore. The replacement is {{python2.pc}} of the package {{python2-dev}}. 
> However, however, that package is only required for the Asterisk Test Suite. It allows building a SIP User Agent, which tests Asterisk. The Test Suite requires the Test Framework, and that can be built only if Asterisk was configured in (1) Developer Mode {{./configure --enable-dev-mode}} and the developer selected the (2) Test Framework in the Compiler Options via
> {{make menuselect}}.
> Then, [PJSUA Python|http://www.pjsip.org/trac/wiki/Python_SIP_Tutorial] is built, a SIP User Agent as Python module. That agent is then leveraged by the Asterisk Test Suite to test the built Asterisk. Because that module is not available as a pre-compiled binary, the build system of Asterisk builds that module. And for this, the Python/C API is [required|https://docs.python.org/2/extending/] which is part of the software package {{python-dev}}
> Consequently, {{python-dev}} is only used by contributors to Asterisk. Only when Asterisk was build in Developer Mode. Only when the Test Framework was enabled in Asterisk. However, the script {{install_prereq}} is targeted at users of Asterisk, not contributors of Asterisk. If the script were targeted at contributors as well, other—much more—software packages are required like {{autoconf}}, {{automake}}, {{git}}, and {{git-review}}.
> Consequently, {{python-dev}} can be removed from the script {{install_prereq}}. Furthermore, {{python-dev}} is only checked if the PJProject was not disabled, the PJProject was detected, and the Developer mode was activated.
> Further analysis showed that the used project [PJSUA Python|http://www.pjsip.org/trac/wiki/Python_SIP_Tutorial] was not ported to Python 3.x although Python 3.x exists since Dec. 2008. This is because the [PJSUA Python|http://www.pjsip.org/trac/wiki/Python_SIP_Tutorial] module was deprecated in Dec. 2013, six years ago. It was replaced with the [PJSUA2 Python|https://www.pjsip.org/docs/book-latest/html/intro_pjsua2.html#building-java-python-and-c-swig-modules] module. Side notes: The latter is compatible with Python 3.x since Aug. 2017, eight years after the release of Python 3.x. The predecessor Python module Py_PJSUA was [deprecated|https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/py_pjsua/DEPRECATED.txt] in Jul. 2008. Back then, Teluu missed the opportunity to be Python 3.x compatible from the start.
> In any case, this issue report is not about upgrading to the current Python module in the PJProject. For this, see see ASTERISK-27787. Until then, Python 2.7 must be used. Therefore, the script {{./configure}} is changed to prefer Python 2.7. If that is not available—yet, after 11 years—‘Python 2.x’ is searched as a fallback. If that is not available, ‘Python’ is searched as before.
> The script {{./configure}} also searches for the binary tool ‘python’, the environment to run Python based scripts. For symmetry, the same succession is followed: Python 2.7, Python 2.x, and Python. Theoretically, the contributor could have a version mismatch because he had installed the Python/C API of 2.7 and not the Python environment of 2.7 but 3.x. In any case, there is no way to avoid this. In a Debian based Linux, a contributor has to install the software package {{python2.7-dev}}.
> This allows the addition of ‘python3’ while searching the Python environment, as a last resort. This, as a side effect, allows the Makefile target ‘full’ even in a minimal Ubuntu 18.04 LTS installation. Because of that, the attached patch fixes ASTERISK-27717 as well.
> Test cases:
> ./configure --without-pjproject-bundled (default of Asterisk 13 LTS)
> ./configure --with-pjproject-bundled (default of Asterisk 16 LTS)
> ./configure --without-pjproject (not bundled, not external)
> ./configure --enable-dev-mode --without-pjproject-bundled
> ./configure --enable-dev-mode --with-pjproject-bundled
> ./configure --enable-dev-mode --without-pjproject
> Python bindings for the SIP user agent in the PJProject:
> # [till 2008|https://github.com/pjsip/pjproject/tree/master/pjsip-apps/src/py_pjsua] ([documentation|http://www.pjsip.org/trac/wiki/Py_PJSUA])
> # [till 2013|https://github.com/pjsip/pjproject/tree/master/pjsip-apps/src/python] ([API|https://www.pjsip.org/python/pjsua.htm])
> # [current|https://github.com/pjsip/pjproject/tree/master/pjsip-apps/src/swig] ([documentation|https://www.pjsip.org/docs/book-latest/html/intro_pjsua2.html#building-java-python-and-c-swig-modules])



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



More information about the asterisk-bugs mailing list