From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 2E8483857703; Thu, 7 Mar 2024 14:25:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2E8483857703 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2E8483857703 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:ea4a:1:5054:ff:fec7:86e4 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709821518; cv=none; b=wuhbZkBLRMDz9/ThXtDRAAOPKmFoZnuzLZkJT0X25avU7NKvD3Hkcczka3NbdFj9COu18hn8vdwWyMs3msGo7mpbvTwph95HtWF+Ry+o1c0al2AS+zFh3TgGzO0iULXvEitF0tM2kFo2yXFO0KgTFjL5gPtppoAj58rbvIEHNmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709821518; c=relaxed/simple; bh=764sZAwAkz9SkKeXqucLLZVFCgL2nGL0tUFxGkeDlIs=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=T8mJR9SZiv6rnDFQ79VemmaZ+1HxsxR+zn7ui6nHl2+m2anPEGDwz/SN0dCVedcUlnQnHsgbUobi3TTvT+dFma/Q6PzD5J4ym59Goj6T7QAIX5YFRF7EVhXKayiFxXeBIK0XbSa8bxQeH9tJ7yEKL0egw4wmCw4FD84BzjXhB0o= ARC-Authentication-Results: i=1; server2.sourceware.org From: Sam James To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org, law@gcc.gnu.org, rguenth@gcc.gnu.org Subject: Re: [PATCH] contrib: Improve dg-extract-results.sh's Python detection In-Reply-To: (Jakub Jelinek's message of "Thu, 7 Mar 2024 15:21:34 +0100") Organization: Gentoo References: <20240307141638.153366-1-sam@gentoo.org> User-Agent: mu4e 1.12.0; emacs 30.0.50 Date: Thu, 07 Mar 2024 14:25:09 +0000 Message-ID: <875xxyjf0a.fsf@gentoo.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Jakub Jelinek writes: > On Thu, Mar 07, 2024 at 02:16:37PM +0000, Sam James wrote: >> 'python' on some systems (e.g. SLES 15) might be Python 2. Prefer ${EPYTHON} >> if defined (used by Gentoo's python-exec wrapping), then python3, then python. > > I'd say EPYTHON is too distro specific, just use for python in python3 python ? > Other scripts just have > #!/usr/bin/env python3 > as the first line and go with that. Sure. Should I add python2 too as well (last), given the script nominally tries to work with it still? > >> contrib/ChangeLog: >> >> * dg-extract-results.sh: Check for python3 before python. >> --- >> contrib/dg-extract-results.sh | 17 ++++++++++------- >> 1 file changed, 10 insertions(+), 7 deletions(-) >> >> diff --git a/contrib/dg-extract-results.sh b/contrib/dg-extract-results.sh >> index 00ef80046f74..2d1cd76fe255 100755 >> --- a/contrib/dg-extract-results.sh >> +++ b/contrib/dg-extract-results.sh >> @@ -28,14 +28,17 @@ >> >> PROGNAME=dg-extract-results.sh >> >> -# Try to use the python version if possible, since it tends to be faster. >> +# Try to use the python version if possible, since it tends to be faster and >> +# produces more stable results. >> PYTHON_VER=`echo "$0" | sed 's/sh$/py/'` >> -if test "$PYTHON_VER" != "$0" && >> - test -f "$PYTHON_VER" && >> - python -c 'import sys, getopt, re, io, datetime, operator; sys.exit (0 if sys.version_info >= (2, 6) else 1)' \ >> - > /dev/null 2> /dev/null; then >> - exec python $PYTHON_VER "$@" >> -fi >> +for python in ${EPYTHON:-python3} python ; do >> + if test "$PYTHON_VER" != "$0" && >> + test -f "$PYTHON_VER" && >> + ${python} -c 'import sys, getopt, re, io, datetime, operator; sys.exit (0 if sys.version_info >= (2, 6) else 1)' \ >> + > /dev/null 2> /dev/null; then >> + exec ${python} $PYTHON_VER "$@" >> + fi >> +done >> >> usage() { >> cat <&2 >> -- >> 2.44.0 > > Jakub