Don't detect the Python shebang line at build-time; Don't use AM_PATH_PYTHON
Olivier Certner <[email protected]> Thu, 06 Apr 2023 14:27:47 +0200
| Newsgroups | gmane.comp.gnu.global.bugs |
|---|---|
| Message-ID | <8082526.l14k6Rhh58@ravel> |
Hello, - What is your environment (OS)? FreeBSD 13 - Which version of Global are you using? 6.6.9 - What did you do? ./configure - What did you expect from it? Don't try to detect a Python installation at build time and don't pickup the corresponding Python executable to generate the shebang line for the Pygments parser. Instead, use a reasonable default line, like "#!/usr/bin/env python", so that resolution happens at run-time. Also, I don't expect './configure --help' to present such options: --with-python-sys-prefix, --with-python_prefix, --with-python_exec_prefix. They are relevant only when a Python module is actually installed (which is not the case for Global). It may however be useful to be able to specify a specific shebang line. Please see the attached patch, which provides '--enable-python-interpreter' to force a Python shebang line (the PYTHON environment variable also works). If you absolutely want to keep the detection-at-compile-time feature (which I advise against), I can propose another patch so that the "detect" special value for '--enable-python-interpreter' triggers some auto-detection at build time. In any case, AM_PATH_PYTHON must not be used as long as no Python module is installed. Regards. -- Olivier Certner
python_shebang.patch
(text/x-patch, 921 B)
--- configure.ac 2023-04-06 14:12:41.226575000 +0200 +++ configure.ac 2023-04-06 14:24:33.865754000 +0200 @@ -43,7 +43,19 @@ dnl dnl for "plugin-factory/pygments_parser.py" dnl -AM_PATH_PYTHON([2.6],,[PYTHON="/usr/bin/env python"]) +m4_define([PYTHON_INTERPRETER],[[/usr/bin/env python]]) +AC_ARG_ENABLE([python-interpreter], + [AS_HELP_STRING([--enable-python-interpreter], + [the Python interpreter to use at run-time in the Pygments plugin]dnl +[ @<:@default=]m4_expand([PYTHON_INTERPRETER])[@:>@])], + [PYTHON=$enableval], + [PYTHON=""]) +AS_IF([test x"$PYTHON" = x"no"], + [AC_MSG_ERROR([a Python interpreter command is needed (even if not installed)])], + [test x"$PYTHON" = x], + [PYTHON="]m4_expand([PYTHON_INTERPRETER])["]) +AC_MSG_NOTICE([using "$PYTHON" as the shebang line's interpreter for 'pygments_parser.py']) +AC_SUBST([PYTHON]) AC_GNU_SOURCE