From patchwork Tue Mar 19 11:02:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 10859407 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2EDF414DE for ; Tue, 19 Mar 2019 11:04:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12D792883D for ; Tue, 19 Mar 2019 11:04:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02D3D28A8B; Tue, 19 Mar 2019 11:04:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A710E2883D for ; Tue, 19 Mar 2019 11:04:44 +0000 (UTC) Received: from localhost ([127.0.0.1]:55248 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6CXz-00088x-Rl for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Mar 2019 07:04:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6CVZ-0006kI-Vu for qemu-devel@nongnu.org; Tue, 19 Mar 2019 07:02:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6CVZ-0008UN-1o for qemu-devel@nongnu.org; Tue, 19 Mar 2019 07:02:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51174) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6CVY-0008Px-Mu for qemu-devel@nongnu.org; Tue, 19 Mar 2019 07:02:12 -0400 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 08536F74D2 for ; Tue, 19 Mar 2019 11:02:12 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-54.ams2.redhat.com [10.36.112.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4931663BA6; Tue, 19 Mar 2019 11:02:10 +0000 (UTC) From: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 11:02:08 +0000 Message-Id: <20190319110208.4944-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.38]); Tue, 19 Mar 2019 11:02:12 +0000 (UTC) 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 v2] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é Reviewed-by: Eric Blake --- Changed in v2: - Rewrote to follow Eric's suggested approach configure | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 7071f52584..028453a5a6 100755 --- a/configure +++ b/configure @@ -901,7 +901,18 @@ fi : ${make=${MAKE-make}} : ${install=${INSTALL-install}} -: ${python=${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= +for binary in "${PYTHON-python3}" python python2 +do + if has "$binary" + then + python="$binary" + break + fi +done : ${smbd=${SMBD-/usr/sbin/smbd}} # Default objcc to clang if available, otherwise use CC @@ -1797,8 +1808,9 @@ EOF exit 0 fi -if ! has $python; then - error_exit "Python not found. Use --python=/path/to/python" +if test -z "$python" +then + error_exit "Python not found. Use --python=/path/to/python" fi # Note that if the Python conditional here evaluates True we will exit