public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zhu, Yonghong" <yonghong.zhu@intel.com>
To: Gary Lin <glin@suse.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Gao, Liming" <liming.gao@intel.com>,
	"Zhu, Yonghong" <yonghong.zhu@intel.com>
Subject: Re: [PATCH 3/3] BaseTools: Read the env variable PYTHON_DEFAULT
Date: Fri, 6 Jul 2018 00:46:10 +0000	[thread overview]
Message-ID: <B9726D6DCCFB8B4CA276A9169B02216D520B6B68@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20180627100757.3405-4-glin@suse.com>

Hi Gary,

The patch 1 and patch 2 are good to me. 
While for this patch 3, I think it is only for developer evaluation, developer can keep it on his local, so I don't prefer to commit it to master.  
I have a task on my plan to migrate BaseTools to Python 3,  maybe this Q3 to finish it.

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Gary Lin [mailto:glin@suse.com] 
Sent: Wednesday, June 27, 2018 6:08 PM
To: edk2-devel@lists.01.org
Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [PATCH 3/3] BaseTools: Read the env variable PYTHON_DEFAULT

When PYTHON_DEFAULT is set as "python3", the bash scripts in PosixLike will perfer python3. Currently, this is for the evaluation of the python3 support and errors from the python3 interperter are expected.

For example, to build OvmfPkg with python3:

$ export PYTHON_DEFAULT=python3
$ ./OvmfPkg/build.sh

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
---
 BaseTools/BinWrappers/PosixLike/BPDG                      | 6 +++++-
 BaseTools/BinWrappers/PosixLike/Ecc                       | 6 +++++-
 BaseTools/BinWrappers/PosixLike/GenDepex                  | 6 +++++-
 BaseTools/BinWrappers/PosixLike/GenFds                    | 6 +++++-
 BaseTools/BinWrappers/PosixLike/GenPatchPcdTable          | 6 +++++-
 BaseTools/BinWrappers/PosixLike/PatchPcdValue             | 6 +++++-
 BaseTools/BinWrappers/PosixLike/Pkcs7Sign                 | 6 +++++-
 BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys | 6 +++++-
 BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign         | 6 +++++-
 BaseTools/BinWrappers/PosixLike/TargetTool                | 6 +++++-
 BaseTools/BinWrappers/PosixLike/Trim                      | 6 +++++-
 BaseTools/BinWrappers/PosixLike/UPT                       | 6 +++++-
 BaseTools/BinWrappers/PosixLike/build                     | 6 +++++-
 13 files changed, 65 insertions(+), 13 deletions(-)

diff --git a/BaseTools/BinWrappers/PosixLike/BPDG b/BaseTools/BinWrappers/PosixLike/BPDG
index 01ae23ddeb4f..aef1bc444a64 100755
--- a/BaseTools/BinWrappers/PosixLike/BPDG
+++ b/BaseTools/BinWrappers/PosixLike/BPDG
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
diff --git a/BaseTools/BinWrappers/PosixLike/Ecc b/BaseTools/BinWrappers/PosixLike/Ecc
index 01ae23ddeb4f..aef1bc444a64 100755
--- a/BaseTools/BinWrappers/PosixLike/Ecc
+++ b/BaseTools/BinWrappers/PosixLike/Ecc
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
diff --git a/BaseTools/BinWrappers/PosixLike/GenDepex b/BaseTools/BinWrappers/PosixLike/GenDepex
index dad174788bc3..c311d76238e4 100755
--- a/BaseTools/BinWrappers/PosixLike/GenDepex
+++ b/BaseTools/BinWrappers/PosixLike/GenDepex
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
diff --git a/BaseTools/BinWrappers/PosixLike/GenFds b/BaseTools/BinWrappers/PosixLike/GenFds
index 01ae23ddeb4f..aef1bc444a64 100755
--- a/BaseTools/BinWrappers/PosixLike/GenFds
+++ b/BaseTools/BinWrappers/PosixLike/GenFds
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
diff --git a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
index 01ae23ddeb4f..aef1bc444a64 100755
--- a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
+++ b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
diff --git a/BaseTools/BinWrappers/PosixLike/PatchPcdValue b/BaseTools/BinWrappers/PosixLike/PatchPcdValue
index 01ae23ddeb4f..aef1bc444a64 100755
--- a/BaseTools/BinWrappers/PosixLike/PatchPcdValue
+++ b/BaseTools/BinWrappers/PosixLike/PatchPcdValue
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
diff --git a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign
index 01ae23ddeb4f..aef1bc444a64 100755
--- a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign
+++ b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
index 1bc1054a3452..d6f3d0e23083 100755
--- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
+++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
index 01ae23ddeb4f..aef1bc444a64 100755
--- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
+++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
diff --git a/BaseTools/BinWrappers/PosixLike/TargetTool b/BaseTools/BinWrappers/PosixLike/TargetTool
index 01ae23ddeb4f..aef1bc444a64 100755
--- a/BaseTools/BinWrappers/PosixLike/TargetTool
+++ b/BaseTools/BinWrappers/PosixLike/TargetTool
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
diff --git a/BaseTools/BinWrappers/PosixLike/Trim b/BaseTools/BinWrappers/PosixLike/Trim
index 6c8dde5bec3e..6ec76c3a45c9 100755
--- a/BaseTools/BinWrappers/PosixLike/Trim
+++ b/BaseTools/BinWrappers/PosixLike/Trim
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
diff --git a/BaseTools/BinWrappers/PosixLike/UPT b/BaseTools/BinWrappers/PosixLike/UPT
index 01ae23ddeb4f..aef1bc444a64 100755
--- a/BaseTools/BinWrappers/PosixLike/UPT
+++ b/BaseTools/BinWrappers/PosixLike/UPT
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
diff --git a/BaseTools/BinWrappers/PosixLike/build b/BaseTools/BinWrappers/PosixLike/build
index 01ae23ddeb4f..aef1bc444a64 100755
--- a/BaseTools/BinWrappers/PosixLike/build
+++ b/BaseTools/BinWrappers/PosixLike/build
@@ -1,8 +1,12 @@
 #!/usr/bin/env bash
 #python `dirname $0`/RunToolFromSource.py `basename $0` $*
 
+# If a python3 command is available and PYTHON_DEFAULT is "python3", # 
+use it in preference to python if test "$PYTHON_DEFAULT" == "python3" 
+&& command -v python3 >/dev/null 2>&1; then
+    python_exe=python3
 # If a python2 command is available, use it in preference to python -if command -v python2 >/dev/null 2>&1; then
+elif command -v python2 >/dev/null 2>&1; then
     python_exe=python2
 fi
 
--
2.17.1



  reply	other threads:[~2018-07-06  0:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-27 10:07 [PATCH 0/3] python3 follow-up patches for BaseTools Gary Lin
2018-06-27 10:07 ` [PATCH 1/3] BaseTools: Remove the old python "not-equal" in DscBuildData.py Gary Lin
2018-06-27 10:07 ` [PATCH 2/3] BaseTools: Unify long and int in Expression.py Gary Lin
2018-06-27 10:07 ` [PATCH 3/3] BaseTools: Read the env variable PYTHON_DEFAULT Gary Lin
2018-07-06  0:46   ` Zhu, Yonghong [this message]
2018-07-06  1:49     ` Gary Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B9726D6DCCFB8B4CA276A9169B02216D520B6B68@SHSMSX103.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox