]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool: Use the Python implementation by default. v1.0
authorBruno Haible <bruno@clisp.org>
Fri, 26 Apr 2024 09:33:06 +0000 (11:33 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 26 Apr 2024 09:33:06 +0000 (11:33 +0200)
* 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.

ChangeLog
gnulib-tool

index 4a2f0601bb47473ac52c878f40607596f675ed1e..378626f208b5b1b7635b6fbbf7c0cf9391a99e2c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-04-26  Bruno Haible  <bruno@clisp.org>
+
+       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  <collin.funk1@gmail.com>
 
        gnulib-tool.py: Remove some unused instance variables.
index 85b62883c607b64c93d10c82481bc98a60a78448..441958ae7e59d5525fee607d7579404708d29532 100755 (executable)
@@ -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" "$@" ;;