From nobody Sun Nov 9 17:49:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155145840280873.46176174158961; Fri, 1 Mar 2019 08:40:02 -0800 (PST) Received: from localhost ([127.0.0.1]:40451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzlCb-0005VO-3j for importer@patchew.org; Fri, 01 Mar 2019 11:40:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzl6o-0000uQ-1a for qemu-devel@nongnu.org; Fri, 01 Mar 2019 11:34:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzl6n-0007Fy-9P for qemu-devel@nongnu.org; Fri, 01 Mar 2019 11:34:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46453) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gzl6j-00074p-C9 for qemu-devel@nongnu.org; Fri, 01 Mar 2019 11:33:59 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3F803088A9C for ; Fri, 1 Mar 2019 16:33:48 +0000 (UTC) Received: from dhcp-17-75.lcy.redhat.com (unknown [10.42.17.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04D5060142; Fri, 1 Mar 2019 16:33:47 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Fri, 1 Mar 2019 16:33:46 +0000 Message-Id: <20190301163346.6545-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 01 Mar 2019 16:33:48 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] configure: automatically pick python3 is available X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Unless overridden via an env var or configure arg, QEMU will only look for the 'python' binary in $PATH. This is unhelpful on distros which are only shipping Python 3.x (eg Fedora) in their default install as, if they comply with PEP 394, the bare 'python' binary won't exist. This changes configure so that by default it will search for all three common python binaries, preferring to find Python 3.x versions. Signed-off-by: Daniel P. Berrang=C3=A9 --- configure | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 540bee19ba..ef2e5bf9f5 100755 --- a/configure +++ b/configure @@ -902,7 +902,10 @@ fi =20 : ${make=3D${MAKE-make}} : ${install=3D${INSTALL-install}} -: ${python=3D${PYTHON-python}} +# We prefer python 3.x. A bare 'python' is traditionally +# python 2.x, but some distros have it as python 3.x, so +# we check that before python2 +: ${python=3D${PYTHON-python3 python python2}} : ${smbd=3D${SMBD-/usr/sbin/smbd}} =20 # Default objcc to clang if available, otherwise use CC @@ -1797,8 +1800,20 @@ EOF exit 0 fi =20 -if ! has $python; then - error_exit "Python not found. Use --python=3D/path/to/python" +try_python=3D"$python" +python=3D +for binary in $try_python +do + if has $binary + then + python=3D$binary + break + fi +done + +if test -z "$python" +then + error_exit "Python not found. Use --python=3D/path/to/python" fi =20 # Note that if the Python conditional here evaluates True we will exit --=20 2.20.1