From nobody Sat Sep 21 03:13:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+103591+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103591+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1682442944; cv=none; d=zohomail.com; s=zohoarc; b=Y5sOYQpSnTzgXjcOSbyLR/pwALbmUzzryLIpvc53+KLOhlG92EhCxwZW7IsQ+5bdG83PZdwdwR8NIkY+aOvYklZU31NYUMnR/MRoV8L9BMHenZ9Zbtx4D2Bo1hsWq3Ubf07ekmZzXzjJFCMtitr950RBMkby3wZhQCGBgB3m1u4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682442944; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=kCvBYVI4PImZL+YXpK3gZdJtgaexvGVxfSPxvtLke0w=; b=G4OX094AyYWBW12v/dz1p7DvyrRKMXU1VmQ0wjpELrF1DwvUkIrFdCp+UdVtlD3fHc5RsVKrCSnfT8wpxHsaerWWquy9hKY3IGoq+P4KnrPTJzuXwShjeFM8GVft5Nbg5hir1aj9uQS+3ztDsHBXb8CL2sOzNu/j4gay1sSorXM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+103591+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1682442944892349.5811627447015; Tue, 25 Apr 2023 10:15:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id hiVWYY1788612xicOKunfbcC; Tue, 25 Apr 2023 10:15:44 -0700 X-Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by mx.groups.io with SMTP id smtpd.web10.85946.1682442943858705458 for ; Tue, 25 Apr 2023 10:15:44 -0700 X-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 3E6A25C00D7; Tue, 25 Apr 2023 13:15:43 -0400 (EDT) X-Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 25 Apr 2023 13:15:43 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeduvddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeftvggs vggttggrucevrhgrnhcuoehrvggsvggttggrsegsshguihhordgtohhmqeenucggtffrrg htthgvrhhnpeetleejgeduleegieejtefhleejkefgieekudfhtdegveehtdekheevffet udffveenucffohhmrghinhepphihphhirdhorhhgnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheprhgvsggvtggtrgessghsughiohdrtghomh X-ME-Proxy: Feedback-ID: i5b994698:Fastmail X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 25 Apr 2023 13:15:42 -0400 (EDT) From: "Rebecca Cran" To: devel@edk2.groups.io, Andrew Fish , Leif Lindholm , Michael D Kinney , Liming Gao , Bob Feng , Yuwei Chen Cc: Rebecca Cran Subject: [edk2-devel] [PATCH 4/6] BaseTools: Update toolsetup.bat and Tests/PythonTest.py to check ver Date: Tue, 25 Apr 2023 11:15:16 -0600 Message-Id: <20230425171518.1584-5-rebecca@bsdio.com> In-Reply-To: <20230425171518.1584-1-rebecca@bsdio.com> References: <20230425171518.1584-1-rebecca@bsdio.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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 X-Gm-Message-State: ywFO12gYWuSLD4SDrUDf8ql1x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1682442944; bh=Lbl/d09pU3qm4ImP6RpZ5wbQQ30kWsK4Bynjyas/fGQ=; h=Cc:Date:From:Reply-To:Subject:To; b=rS6qhtzgzpqVUvA9jz1Zt/kz9Ci7YVhMnhCB/rcaH/wFVq/mM/bPEAQ6VdFal7IzBlU C1biQDvzN+O3bCdLhSW3mfme/+fppnHImpyUu5HznFNsjJkuMkuRJ96+p5aEAjvfjbTMB kFHqEMbIZ1D1FMCDNTW+R3LmA9/QrrI/js0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1682442946918100019 Content-Type: text/plain; charset="utf-8" Update toolsetup.bat and Tests/PythonTest.py to check if we're running a version of Python that's compatible with BaseTools and the Pip BaseTools. Since edk2-pytool-extensions (https://pypi.org/project/edk2-pytool-extensions/) requires Python 3.9 or newer, set that as the minimum version EDK2 requires. Signed-off-by: Rebecca Cran --- BaseTools/Tests/PythonTest.py | 21 ++++++- BaseTools/toolsetup.bat | 61 +++++++++++--------- 2 files changed, 53 insertions(+), 29 deletions(-) diff --git a/BaseTools/Tests/PythonTest.py b/BaseTools/Tests/PythonTest.py index ec44c7947086..1716f78b5217 100644 --- a/BaseTools/Tests/PythonTest.py +++ b/BaseTools/Tests/PythonTest.py @@ -1,9 +1,26 @@ ## @file -# Test whether PYTHON_COMMAND is available +# Test whether PYTHON_COMMAND is available and the +# minimum Python version is installed. # # Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # =20 +import sys + if __name__ =3D=3D '__main__': - print('TRUE') + # Check if the major and minor versions required were specified. + if len(sys.argv) >=3D 3: + req_major_version =3D int(sys.argv[1]) + req_minor_version =3D int(sys.argv[2]) + else: + # If the minimum version wasn't specified on the command line, + # default to 3.9 which was the minimum required on 2023-04-24. + req_major_version =3D 3 + req_minor_version =3D 9 + + if sys.version_info.major =3D=3D req_major_version and \ + sys.version_info.minor >=3D req_minor_version: + sys.exit(0) + else: + sys.exit(1) diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat index 29a630b9035c..66df628eac5f 100755 --- a/BaseTools/toolsetup.bat +++ b/BaseTools/toolsetup.bat @@ -12,6 +12,8 @@ @echo off pushd . set SCRIPT_ERROR=3D0 +set PYTHON_VER_MAJOR=3D3 +set PYTHON_VER_MINOR=3D9 =20 @REM ############################################################## @REM # You should not have to modify anything below this line @@ -322,17 +324,19 @@ goto check_build_environment ) ) =20 -:defined_python +@REM Check Python environment =20 if not defined PYTHON_COMMAND ( set PYTHON_COMMAND=3Dpy -3 - py -3 %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1 - setlocal enabledelayedexpansion - set /p PythonCheck=3D<"PythonCheck.txt" - del PythonCheck.txt - if "!PythonCheck!" NEQ "TRUE" ( + py -3 %BASE_TOOLS_PATH%\Tests\PythonTest.py %PYTHON_VER_MAJOR% %PYTHON_V= ER_MINOR% >NUL 2>NUL + if %ERRORLEVEL% EQU 1 ( + echo. + echo !!! ERROR !!! Python %PYTHON_VER_MAJOR%.%PYTHON_VER_MINOR% or new= er is required. + echo. + goto end + ) + if %ERRORLEVEL% NEQ 0 ( if not defined PYTHON_HOME if not defined PYTHONHOME ( - endlocal set PYTHON_COMMAND=3D echo. echo !!! ERROR !!! Binary python tools are missing. @@ -345,8 +349,6 @@ if not defined PYTHON_COMMAND ( ) ) =20 -endlocal - if defined PYTHON_HOME ( if EXIST "%PYTHON_HOME%" ( set PYTHON_COMMAND=3D%PYTHON_HOME%\python.exe @@ -358,27 +360,30 @@ if defined PYTHON_HOME ( ) ) =20 -%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>= &1 - setlocal enabledelayedexpansion - set /p PythonCheck=3D<"PythonCheck.txt" - del PythonCheck.txt - if "!PythonCheck!" NEQ "TRUE" ( - echo. - echo ! ERROR ! PYTHON_COMMAND=3D"%PYTHON_COMMAND%" is not installed o= r added to environment variables - echo. - goto end +%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py %PYTHON_VER_MAJOR% = %PYTHON_VER_MINOR% >NUL 2>NUL +if %ERRORLEVEL% EQU 1 ( + echo. + echo !!! ERROR !!! Python %PYTHON_VER_MAJOR%.%PYTHON_VER_MINOR% or newer= is required. + echo. + goto end +) +if %ERRORLEVEL% NEQ 0 ( + echo. + echo !!! ERROR !!! PYTHON_COMMAND=3D"%PYTHON_COMMAND%" does not exist o= r is not a Python interpreter. + echo. + goto end ) =20 endlocal =20 - %PYTHON_COMMAND% -c "import edk2basetools" >NUL 2>NUL - if %ERRORLEVEL% EQU 0 ( - goto use_pip_basetools - ) else ( - REM reset ERRORLEVEL - type nul>nul - goto use_builtin_basetools - ) +%PYTHON_COMMAND% -c "import edk2basetools" >NUL 2>NUL +if %ERRORLEVEL% EQU 0 ( + goto use_pip_basetools +) else ( + REM reset ERRORLEVEL + type nul>nul + goto use_builtin_basetools +) =20 :use_builtin_basetools @echo Using EDK2 in-source Basetools @@ -466,5 +471,7 @@ set VS2015=3D set VS2013=3D set VS2012=3D set VSTool=3D +set PYTHON_VER_MAJOR=3D +set PYTHON_VER_MINOR=3D +set SCRIPT_ERROR=3D popd - --=20 2.40.0.windows.1 -=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 (#103591): https://edk2.groups.io/g/devel/message/103591 Mute This Topic: https://groups.io/mt/98497587/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-