From nobody Mon May 6 13:31:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+43767+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+43767+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1563244575; cv=none; d=zoho.com; s=zohoarc; b=ROFnsQq+7jaKUKpKUv5dXNsEY7jzkoByyxo//aQItcS9THI3G3J1Xfbzri+M0bkNkAiV+WURvjOHSRb4Tb/gQio3C9s958eScO+PZ8N71KS7TEsv9gprjnkILQjIB1mItkHtGQudCLX0YgqFmJk2ugpZq9wvxZyipH7J+81VzMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563244575; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=o+8IeqTyZ/fICv8GEqnylANpKhAwEV4K5S1ORT5TkM4=; b=XYzduq9EDJGuCl7eetPMHZul/FSGnAryB8LgYhICfU4xYclIWx7HRICuMiOTHa8Me/qSOd2Ns0rCZ+bgl5tiUlMAp8tBBuHs867Uu6GVETST9XORXUVV447YD9J/AZcekwYrRji/WW5taaJE4b85PwEZ6Pfo6JaiY+nv8Q8t+sU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+43767+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1563244575008805.7233466751842; Mon, 15 Jul 2019 19:36:15 -0700 (PDT) Return-Path: X-Received: from muon.bsdio.com (muon.bsdio.com [65.103.231.193]) by groups.io with SMTP; Mon, 15 Jul 2019 19:36:14 -0700 X-Received: from muon.bsdio.com (localhost [127.0.0.1]) by muon.bsdio.com (Postfix) with ESMTP id 0F06677E36; Mon, 15 Jul 2019 20:36:34 -0600 (MDT) X-Received: from muon.bsdio.com ([127.0.0.1]) by muon.bsdio.com (muon.bsdio.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id q3lhqkS6X5kg; Mon, 15 Jul 2019 20:36:33 -0600 (MDT) X-Received: from photon.int.bluestop.org (unknown [10.0.10.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by muon.bsdio.com (Postfix) with ESMTPSA; Mon, 15 Jul 2019 20:36:33 -0600 (MDT) From: rebecca@bsdio.com To: devel@edk2.groups.io, lersek@redhat.com, bob.c.feng@intel.com, liming.gao@intel.com, leif.lindholm@linaro.org, michael.d.kinney@intel.com, afish@apple.com Cc: Rebecca Cran Subject: [edk2-devel] [PATCH v2] edksetup.sh: Simplify SetupPython3 and SetupPython functions. Date: Mon, 15 Jul 2019 20:36:06 -0600 Message-Id: <20190716023606.54076-1-rebecca@bsdio.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rebecca@bsdio.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1563244574; bh=n6qAvgi2PqRd2wysamX1n3kqOClJKz6XECt58ljoM7k=; h=Cc:Date:From:Reply-To:Subject:To; b=nDJAidbcQTOBDLLI7jMq018rfgA4E0VxE7Wnz0ANj74DNzYKzb7xKlgS0mTHQu0VjuM IQ7+4S8H4At9ZpAN6iCy8COgceWDryocSRF23lGwvgP842mwQgeMue0I8j54w5Aqt5ADG kCSJwgEb+6gjlPZHIz8D+xfLfzSSZ/6XX/A= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" On Linux, "whereis" matches python3, python3.7, as well as man pages, libs etc. While on macOS it only matches the specified name, and so misses python3.7. Improve this by looping over potential version numbers and seeing if such a binary exists and can be executed. Signed-off-by: Rebecca Cran Reviewed-by: Laszlo Ersek --- edksetup.sh | 44 +++++++------------------------------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/edksetup.sh b/edksetup.sh index 06d2f041e6..5b90e55ed8 100755 --- a/edksetup.sh +++ b/edksetup.sh @@ -107,24 +107,10 @@ function SetupEnv() =20 function SetupPython3() { - if [ $origin_version ];then - origin_version=3D - fi - for python in $(whereis python3) - do - python=3D$(echo $python | grep "[[:digit:]]$" || true) - python_version=3D${python##*python} - if [ -z "${python_version}" ] || (! command -v $python >/dev/null 2>&1= );then - continue - fi - if [ -z $origin_version ];then - origin_version=3D$python_version - export PYTHON_COMMAND=3D$python - continue - fi - if [[ "$origin_version" < "$python_version" ]]; then - origin_version=3D$python_version + for ((pyver=3D15; pyver>=3D1; --pyver)); do + if python=3D$(command -v python3.$pyver); then export PYTHON_COMMAND=3D$python + break fi done return 0 @@ -146,27 +132,11 @@ function SetupPython() SetupPython3 fi =20 - if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE !=3D TRUE ] - then - if [ $origin_version ];then - origin_version=3D - fi - for python in $(whereis python2) - do - python=3D$(echo $python | grep "[[:digit:]]$" || true) - python_version=3D${python##*python} - if [ -z "${python_version}" ] || (! command -v $python >/dev/null 2>= &1);then - continue - fi - if [ -z $origin_version ] - then - origin_version=3D$python_version - export PYTHON_COMMAND=3D$python - continue - fi - if [[ "$origin_version" < "$python_version" ]]; then - origin_version=3D$python_version + if [ -n "$PYTHON3_ENABLE" ] && [ "$PYTHON3_ENABLE" !=3D "TRUE" ]; then + for ((pyver=3D10; pyver>=3D1; --pyver)); do + if python=3D$(command -v python2.$pyver); then export PYTHON_COMMAND=3D$python + break fi done return 0 --=20 2.22.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#43767): https://edk2.groups.io/g/devel/message/43767 Mute This Topic: https://groups.io/mt/32485955/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-