bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnulib-tool: Use the Python implementation by default


From: Bruno Haible
Subject: gnulib-tool: Use the Python implementation by default
Date: Fri, 26 Apr 2024 11:48:03 +0200

I committed this patch, which activates the Python rewrite of gnulib-tool
for all users who have Python installed, without the need to set any
environment variable. I'll make announcements to info-gnu and planet.gnu.org
soon.

Also I couldn't resist pushing a tag named 'v1.0'. We don't make releases,
but it's an indication that Gnulib is mature now.

Many thanks to Dmitry Selyutin for the ground work in 2012, and to Collin Funk
for the finishing work in the last two months!


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.

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" "$@" ;;






reply via email to

[Prev in Thread] Current Thread [Next in Thread]