Summary: | ASTERISK-28824: BuildSystem: Search for Python/C API when possibly needed only. | ||
Reporter: | Alexander Traud (traud) | Labels: | patch |
Date Opened: | 2020-04-12 09:47:11 | Date Closed: | 2020-04-13 16:51:35 |
Priority: | Minor | Regression? | |
Status: | Closed/Complete | Components: | Core/BuildSystem |
Versions: | 13.32.0 16.9.0 17.3.0 | Frequency of Occurrence | |
Related Issues: | |||
Environment: | Attachments: | ( 0) python3.patch | |
Description: | 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]) | ||
Comments: | By: Asterisk Team (asteriskteam) 2020-04-12 09:47:13.062-0500 Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report. Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process]. Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur. By: Friendly Automation (friendly-automation) 2020-04-13 16:51:36.927-0500 Change 14176 merged by Friendly Automation: BuildSystem: Search for Python/C API when possibly needed only. [https://gerrit.asterisk.org/c/asterisk/+/14176|https://gerrit.asterisk.org/c/asterisk/+/14176] By: Friendly Automation (friendly-automation) 2020-04-13 16:52:51.792-0500 Change 14177 merged by Friendly Automation: BuildSystem: Search for Python/C API when possibly needed only. [https://gerrit.asterisk.org/c/asterisk/+/14177|https://gerrit.asterisk.org/c/asterisk/+/14177] By: Friendly Automation (friendly-automation) 2020-04-13 16:56:21.529-0500 Change 14175 merged by Friendly Automation: BuildSystem: Search for Python/C API when possibly needed only. [https://gerrit.asterisk.org/c/asterisk/+/14175|https://gerrit.asterisk.org/c/asterisk/+/14175] By: Friendly Automation (friendly-automation) 2020-04-13 17:23:11.308-0500 Change 14149 merged by Friendly Automation: BuildSystem: Search for Python/C API when possibly needed only. [https://gerrit.asterisk.org/c/asterisk/+/14149|https://gerrit.asterisk.org/c/asterisk/+/14149] By: Friendly Automation (friendly-automation) 2020-04-30 10:51:41.939-0500 Change 14369 merged by George Joseph: BuildSystem: Search for Python/C API when possibly needed only. [https://gerrit.asterisk.org/c/asterisk/+/14369|https://gerrit.asterisk.org/c/asterisk/+/14369] |