From: Bruno Haible Date: Fri, 26 Apr 2024 09:33:06 +0000 (+0200) Subject: gnulib-tool: Use the Python implementation by default. X-Git-Tag: v1.0^0 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=d4ec02b3cc70cddaaa5183cc5a45814e0afb2292;p=gnulib.git gnulib-tool: Use the Python implementation by default. * gnulib-tool: If GNULIB_TOOL_IMPL is not set: Use the Python implementation if a suitable 'python3' program is found in $PATH; otherwise print a warning and use the shell implementation. --- diff --git a/ChangeLog b/ChangeLog index 4a2f0601bb..378626f208 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-04-26 Bruno Haible + + gnulib-tool: Use the Python implementation by default. + * gnulib-tool: If GNULIB_TOOL_IMPL is not set: Use the Python + implementation if a suitable 'python3' program is found in $PATH; + otherwise print a warning and use the shell implementation. + 2024-04-26 Collin Funk gnulib-tool.py: Remove some unused instance variables. diff --git a/gnulib-tool b/gnulib-tool index 85b62883c6..441958ae7e 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -140,7 +140,22 @@ func_gnulib_dir () func_gnulib_dir case "$GNULIB_TOOL_IMPL" in - '' | sh) + '') + # Use the Python implementation if a suitable Python version is found + # in $PATH. This is the same Python version test as in gnulib-tool.py. + if (python3 --version) >/dev/null 2>/dev/null \ + && case `python3 --version 2>&1` in + Python\ 3.[0-6] | Python\ 3.[0-6].*) false ;; + Python\ 3.*) true ;; + *) false ;; + esac; then + exec "$gnulib_dir/gnulib-tool.py" "$@" + else + echo "gnulib-tool: warning: python3 not found or too old, using the slow shell-based implementation" 1>&2 + exec "$gnulib_dir/gnulib-tool.sh" "$@" + fi + ;; + sh) exec "$gnulib_dir/gnulib-tool.sh" "$@" ;; py) exec "$gnulib_dir/gnulib-tool.py" "$@" ;;