[edk2-devel] [PATCH] Python run fail if env variable PYTHON_HOME is not set

Cheng, Ching JenX posted 1 patch 4 years, 8 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py | 2 ++
1 file changed, 2 insertions(+)
[edk2-devel] [PATCH] Python run fail if env variable PYTHON_HOME is not set
Posted by Cheng, Ching JenX 4 years, 8 months ago
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=2041

In Platform\Intel\MinPlatformPkg\Tools\Fsp\RebaseFspBinBaseAddress.py
It will run another python code.
But if the environment variable "PYTHON_HOME" is not exist
and we didn't add any python's path to "PATH".
It will cause error because python command not found.

the error message as below:
'python' is not recognized as an internal or external command,
operable program or batch file.

So we set the python's path from which execute the python code
if PYTHON_HOME was not exist.

Cc: Amy Chan <amy.chan@intel.com>
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Ching JenX Cheng <ching.jenx.cheng@intel.com>
---
 Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py
index 406e5ec130..1d72b4112f 100644
--- a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py
+++ b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddress.py
@@ -76,6 +76,8 @@ file.close()
 pythontool = 'python'
 if 'PYTHON_HOME' in os.environ:
     pythontool = os.environ['PYTHON_HOME'] + os.sep + 'python'
+else:
+    pythontool = sys.executable
 Process = subprocess.Popen([pythontool, splitFspBinPath, "info","-f",fspBinFilePath], stdout=subprocess.PIPE)
 Output = Process.communicate()[0]
 FsptInfo = Output.rsplit(b"FSP_M", 1);
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#46025): https://edk2.groups.io/g/devel/message/46025
Mute This Topic: https://groups.io/mt/32941571/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] Python run fail if env variable PYTHON_HOME is not set
Posted by Chiu, Chasel 4 years, 8 months ago
Please correct subject as you are modifying edk2-platform files:  --subject-prefix="edk2-platforms: PATCH"
Also the RebaseAndPatchFspBinBaseAddress.py should be obsolete soon, so please focus on RebaseFspBinBaseAddress.py.

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Cheng, Ching JenX
> Sent: Monday, August 19, 2019 3:21 PM
> To: devel@edk2.groups.io
> Cc: Chan, Amy <amy.chan@intel.com>; Kubacki, Michael A
> <michael.a.kubacki@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>;
> Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Gao, Liming
> <liming.gao@intel.com>
> Subject: [edk2-devel] [PATCH] Python run fail if env variable PYTHON_HOME is
> not set
> 
> BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=2041
> 
> In Platform\Intel\MinPlatformPkg\Tools\Fsp\RebaseFspBinBaseAddress.py
> It will run another python code.
> But if the environment variable "PYTHON_HOME" is not exist and we didn't
> add any python's path to "PATH".
> It will cause error because python command not found.
> 
> the error message as below:
> 'python' is not recognized as an internal or external command, operable
> program or batch file.
> 
> So we set the python's path from which execute the python code if
> PYTHON_HOME was not exist.
> 
> Cc: Amy Chan <amy.chan@intel.com>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Signed-off-by: Ching JenX Cheng <ching.jenx.cheng@intel.com>
> ---
> 
> Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAddre
> ss.py | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git
> a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAdd
> ress.py
> b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAd
> dress.py
> index 406e5ec130..1d72b4112f 100644
> ---
> a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAdd
> ress.py
> +++
> b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseAndPatchFspBinBaseAd
> +++ dress.py
> @@ -76,6 +76,8 @@ file.close()
>  pythontool = 'python'
>  if 'PYTHON_HOME' in os.environ:
>      pythontool = os.environ['PYTHON_HOME'] + os.sep + 'python'
> +else:
> +    pythontool = sys.executable
>  Process = subprocess.Popen([pythontool, splitFspBinPath,
> "info","-f",fspBinFilePath], stdout=subprocess.PIPE)  Output =
> Process.communicate()[0]  FsptInfo = Output.rsplit(b"FSP_M", 1);
> --
> 2.21.0.windows.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#46029): https://edk2.groups.io/g/devel/message/46029
Mute This Topic: https://groups.io/mt/32941571/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-