[edk2-devel] [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME

Guo, Gua posted 1 patch 11 months ago
Failed in applying to current master (apply log)
BaseTools/toolsetup.bat | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
[edk2-devel] [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME
Posted by Guo, Gua 11 months ago
From: Gua Guo <gua.guo@intel.com>

Ideally behavior is like below order that can support one local build
machine, clone multiple Edk2, some of edk2 repo use old tag and
some of edk2 repo use new tag, they can both support on one machine.

1. if defined PYTHON_COMMAND only
   - use PYTHON_COMMAND = user assigned
2. if not defined PYTHON_COMMAND, auto detect py -3
   - use PYTHON_COMMAND = py -3
3. if defined PYTHON_COMMAND and PYTHON_HOME, use PYTHON_COMMAND
   - use PYTHON_COMMAND = user assigned
4. if defined PYTHON_HOME only,
   - use PYTHON_COMMAND = %PYTHON_HOME%/python.exe

SCRIPT_ERROR should return for paraent batch file to consume
for error handle.

Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
---
 BaseTools/toolsetup.bat | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat
index 9521f67c02..8aef28192e 100755
--- a/BaseTools/toolsetup.bat
+++ b/BaseTools/toolsetup.bat
@@ -313,23 +313,25 @@ if not defined PYTHON_COMMAND (
   )
 )
 
-if defined PYTHON_HOME (
-  if EXIST "%PYTHON_HOME%" (
-    set PYTHON_COMMAND=%PYTHON_HOME%\python.exe
-  ) else (
-    echo .
-    echo !!! ERROR !!!  PYTHON_HOME="%PYTHON_HOME%" does not exist.
-    echo .
-    goto end
+if not defined PYTHON_COMMAND (
+  if defined PYTHON_HOME (
+    if EXIST "%PYTHON_HOME%" (
+      set PYTHON_COMMAND=%PYTHON_HOME%\python.exe
+    ) else (
+      echo .
+      echo !!! ERROR !!!  PYTHON_HOME="%PYTHON_HOME%" does not exist.
+      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
+  %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.
@@ -447,5 +449,4 @@ set VS2015=
 set VSTool=
 set PYTHON_VER_MAJOR=
 set PYTHON_VER_MINOR=
-set SCRIPT_ERROR=
 popd
-- 
2.39.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105326): https://edk2.groups.io/g/devel/message/105326
Mute This Topic: https://groups.io/mt/99141348/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME
Posted by Rebecca Cran 11 months ago
On 5/25/23 6:09 PM, gua.guo@intel.com wrote:

>   
> -%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
> +  %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 PYTHON_COMMAND is already defined we do still want to check it's a 
version we can use. So I don't think this part of the change is correct.


-- 

Rebecca Cran



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105335): https://edk2.groups.io/g/devel/message/105335
Mute This Topic: https://groups.io/mt/99141348/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME
Posted by Guo, Gua 11 months ago
@Rebecca Cran

I update v2 patch on the PR https://github.com/tianocore/edk2/pull/4431

Could you help to check about whether meet your expectation ?

Thanks,
Gua

-----Original Message-----
From: Rebecca Cran <rebecca@bsdio.com> 
Sent: Saturday, May 27, 2023 12:30 AM
To: Guo, Gua <gua.guo@intel.com>; devel@edk2.groups.io
Cc: Gao, Liming <gaoliming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>; Chen, Christine <yuwei.chen@intel.com>
Subject: Re: [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME

On 5/25/23 6:09 PM, gua.guo@intel.com wrote:

>   
> -%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
> +  %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 PYTHON_COMMAND is already defined we do still want to check it's a version we can use. So I don't think this part of the change is correct.


-- 

Rebecca Cran



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105336): https://edk2.groups.io/g/devel/message/105336
Mute This Topic: https://groups.io/mt/99141348/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME
Posted by Rebecca Cran 11 months ago
That looks good. Thanks!


-- 

Rebecca Cran


On 5/26/23 10:56 AM, Guo, Gua wrote:
> @Rebecca Cran
>
> I update v2 patch on the PR https://github.com/tianocore/edk2/pull/4431
>
> Could you help to check about whether meet your expectation ?
>
> Thanks,
> Gua
>
> -----Original Message-----
> From: Rebecca Cran <rebecca@bsdio.com>
> Sent: Saturday, May 27, 2023 12:30 AM
> To: Guo, Gua <gua.guo@intel.com>; devel@edk2.groups.io
> Cc: Gao, Liming <gaoliming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>; Chen, Christine <yuwei.chen@intel.com>
> Subject: Re: [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME
>
> On 5/25/23 6:09 PM, gua.guo@intel.com wrote:
>
>>    
>> -%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
>> +  %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 PYTHON_COMMAND is already defined we do still want to check it's a version we can use. So I don't think this part of the change is correct.
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105337): https://edk2.groups.io/g/devel/message/105337
Mute This Topic: https://groups.io/mt/99141348/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-