public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME
@ 2023-05-26  0:09 Guo, Gua
  2023-05-26 16:29 ` Rebecca Cran
  0 siblings, 1 reply; 4+ messages in thread
From: Guo, Gua @ 2023-05-26  0:09 UTC (permalink / raw)
  To: devel; +Cc: gua.guo, Rebecca Cran, Liming Gao, Bob Feng, Yuwei Chen

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME
  2023-05-26  0:09 [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME Guo, Gua
@ 2023-05-26 16:29 ` Rebecca Cran
  2023-05-26 16:56   ` Guo, Gua
  0 siblings, 1 reply; 4+ messages in thread
From: Rebecca Cran @ 2023-05-26 16:29 UTC (permalink / raw)
  To: gua.guo, devel; +Cc: Liming Gao, Bob Feng, Yuwei Chen

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME
  2023-05-26 16:29 ` Rebecca Cran
@ 2023-05-26 16:56   ` Guo, Gua
  2023-05-26 17:12     ` Rebecca Cran
  0 siblings, 1 reply; 4+ messages in thread
From: Guo, Gua @ 2023-05-26 16:56 UTC (permalink / raw)
  To: Rebecca Cran, devel@edk2.groups.io
  Cc: Gao, Liming, Feng, Bob C, Chen, Christine

@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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME
  2023-05-26 16:56   ` Guo, Gua
@ 2023-05-26 17:12     ` Rebecca Cran
  0 siblings, 0 replies; 4+ messages in thread
From: Rebecca Cran @ 2023-05-26 17:12 UTC (permalink / raw)
  To: Guo, Gua, devel@edk2.groups.io; +Cc: Gao, Liming, Feng, Bob C, Chen, Christine

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.
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-26 17:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-26  0:09 [PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME Guo, Gua
2023-05-26 16:29 ` Rebecca Cran
2023-05-26 16:56   ` Guo, Gua
2023-05-26 17:12     ` Rebecca Cran

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox