public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/python: look for python, then python 3 at configure time
@ 2022-07-04 16:27 Andrew Burgess
  2022-07-15 17:12 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2022-07-04 16:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

It is possible that a system might have a python3 executable, but no
python executable.  For example, on my Fedora system the python2
package provides /usr/bin/python2, the python3 package provides
/usr/bin/python3, and the python-unversioned-command package provides
/usr/bin/python, which picks between python2 and python3.

It is quite possible to only have python3 available on a system.

Currently, when GDB configures, it looks for a 'python' executable.
If non is found then GDB will be built without python support.  Or the
user needs to configure using --with-python=/usr/bin/python3.

This commit updates GDB's configure.ac script to first look for
'python', and then 'python3'.  Now, on a system that only has a
python3 executable, GDB will automatically find, and use that in order
to provide python support, no user supplied configure arguments are
needed.

I've tested this on my local machine by removing the
python-unversioned-command package, confirming that there is no longer
a 'python' executable in my $PATH, and then rebuilding GDB from
scratch.  GDB with this patch has python support.
---
 gdb/configure    | 12 +++++++++---
 gdb/configure.ac |  3 ++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/gdb/configure b/gdb/configure
index 1b821390801..4b5e031bff9 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -11098,8 +11098,11 @@ else
     case "${with_python}" in
     yes | auto)
       if test "${build}" = "${host}"; then
-        # Extract the first word of "python", so it can be a program name with args.
-set dummy python; ac_word=$2
+        # Look first for 'python', then 'python3'.
+        for ac_prog in python python3
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if ${ac_cv_path_python_prog_path+:} false; then :
@@ -11125,7 +11128,6 @@ done
   done
 IFS=$as_save_IFS
 
-  test -z "$ac_cv_path_python_prog_path" && ac_cv_path_python_prog_path="missing"
   ;;
 esac
 fi
@@ -11139,6 +11141,10 @@ $as_echo "no" >&6; }
 fi
 
 
+  test -n "$python_prog_path" && break
+done
+test -n "$python_prog_path" || python_prog_path="missing"
+
         if test "${python_prog_path}" = missing; then
           python_prog=missing
         else
diff --git a/gdb/configure.ac b/gdb/configure.ac
index bf03b875dfe..b681988d7a4 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -811,7 +811,8 @@ else
     case "${with_python}" in
     yes | auto)
       if test "${build}" = "${host}"; then
-        AC_PATH_PROG(python_prog_path, python, missing)
+        # Look first for 'python', then 'python3'.
+        AC_PATH_PROGS(python_prog_path, [python python3], missing)
         if test "${python_prog_path}" = missing; then
           python_prog=missing
         else
-- 
2.25.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb/python: look for python, then python 3 at configure time
  2022-07-04 16:27 [PATCH] gdb/python: look for python, then python 3 at configure time Andrew Burgess
@ 2022-07-15 17:12 ` Tom Tromey
  2022-07-18 10:35   ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2022-07-15 17:12 UTC (permalink / raw)
  To: Andrew Burgess via Gdb-patches; +Cc: Andrew Burgess

>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:

Andrew> This commit updates GDB's configure.ac script to first look for
Andrew> 'python', and then 'python3'.  Now, on a system that only has a
Andrew> python3 executable, GDB will automatically find, and use that in order
Andrew> to provide python support, no user supplied configure arguments are
Andrew> needed.

This seems fine to me.  Thanks.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb/python: look for python, then python 3 at configure time
  2022-07-15 17:12 ` Tom Tromey
@ 2022-07-18 10:35   ` Andrew Burgess
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2022-07-18 10:35 UTC (permalink / raw)
  To: Tom Tromey, Andrew Burgess via Gdb-patches

Tom Tromey <tom@tromey.com> writes:

>>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Andrew> This commit updates GDB's configure.ac script to first look for
> Andrew> 'python', and then 'python3'.  Now, on a system that only has a
> Andrew> python3 executable, GDB will automatically find, and use that in order
> Andrew> to provide python support, no user supplied configure arguments are
> Andrew> needed.
>
> This seems fine to me.  Thanks.

Thanks, pushed.

Andrew


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-18 10:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04 16:27 [PATCH] gdb/python: look for python, then python 3 at configure time Andrew Burgess
2022-07-15 17:12 ` Tom Tromey
2022-07-18 10:35   ` Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).