From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from cxsh.intel-email.com (cxsh.intel-email.com [121.46.250.151]) by mx.groups.io with SMTP id smtpd.web11.12028.1682565074117158853 for ; Wed, 26 Apr 2023 20:11:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@byosoft.com.cn header.s=cloud-union header.b=qjNp4bGT; spf=pass (domain: byosoft.com.cn, ip: 121.46.250.151, mailfrom: gaoliming@byosoft.com.cn) Received: from cxsh.intel-email.com (localhost [127.0.0.1]) by cxsh.intel-email.com (Postfix) with ESMTP id 07601DDA7B0 for ; Thu, 27 Apr 2023 11:11:11 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=byosoft.com.cn; s=cloud-union; t=1682565071; bh=U9LXt/ziGZiKrPvPsW5ibMi8h7lSobX4a6k/piNfk3M=; h=From:To:References:In-Reply-To:Subject:Date; b=qjNp4bGTlBP9S1PULkWLuhndmuND6mG/iKgJcLxxYPz5quE3FMZ/QWisQBbgCp2SC NOEqMaW2/ZUNVtAL9cQo3Z2hs8hcHDyW3N7+uvFSa6pbjKb+l/HOO8ud6FE3T6jVV5 GLWzKU3+twdyHS2E+Retr13VKb1JP8Fh3vBiTEs4= Received: from localhost (localhost [127.0.0.1]) by cxsh.intel-email.com (Postfix) with ESMTP id 02C5DDDA7CC for ; Thu, 27 Apr 2023 11:11:11 +0800 (CST) Received: from cxsh.intel-email.com (localhost [127.0.0.1]) by cxsh.intel-email.com (Postfix) with ESMTP id C64CCDDA7D9 for ; Thu, 27 Apr 2023 11:11:10 +0800 (CST) Authentication-Results: cxsh.intel-email.com; none Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by cxsh.intel-email.com (Postfix) with SMTP id 70798DDA7FA for ; Thu, 27 Apr 2023 11:11:07 +0800 (CST) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Thu, 27 Apr 2023 11:10:56 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 58.246.60.130 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , , "'Andrew Fish'" , "'Leif Lindholm'" , "'Michael D Kinney'" , "'Bob Feng'" , "'Yuwei Chen'" References: <20230425171518.1584-1-rebecca@bsdio.com> <20230425171518.1584-5-rebecca@bsdio.com> In-Reply-To: <20230425171518.1584-5-rebecca@bsdio.com> Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BBVENIIDQvNl0gQmFzZVRvb2xzOiBVcGRhdGUgdG9vbHNldHVwLmJhdCBhbmQgVGVzdHMvUHl0aG9uVGVzdC5weSB0byBjaGVjayB2ZXI=?= Date: Thu, 27 Apr 2023 11:11:00 +0800 Message-ID: <037301d978b5$e4cacd10$ae606730$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQG+/FCFtNYAdimVhsRmpz9YFH8iKwIGmpjSr2M9aVA= Sender: "gaoliming" Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Rebecca: This change will break some development machines those have not installed Python 3.9 or above. Now, those machines can still work. =20 I suggest to report warning message first if the python version doesn't match. Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: devel@edk2.groups.io =B4=FA=B1= =ED Rebecca Cran > =B7=A2=CB=CD=CA=B1=BC=E4: 2023=C4=EA4=D4=C226=C8=D5 1:15 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io; Andrew Fish ; = Leif > Lindholm ; Michael D Kinney > ; Liming Gao ; > Bob Feng ; Yuwei Chen > =B3=AD=CB=CD: Rebecca Cran > =D6=F7=CC=E2: [edk2-devel] [PATCH 4/6] BaseTools: Update toolsetup.bat an= d > Tests/PythonTest.py to check ver >=20 > 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. >=20 > 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. >=20 > Signed-off-by: Rebecca Cran > --- > BaseTools/Tests/PythonTest.py | 21 ++++++- > BaseTools/toolsetup.bat | 61 +++++++++++--------- > 2 files changed, 53 insertions(+), 29 deletions(-) >=20 > diff --git a/BaseTools/Tests/PythonTest.py b/BaseTools/Tests/PythonTest.p= y > 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% %P > YTHON_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 ( > 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 >Pyth > onCheck.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 or added to environment variables > - echo. > - goto end > +%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py %PYT > HON_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 or 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 > - > -- > 2.40.0.windows.1 >=20 >=20 >=20 >=20 >=20