* [PATCH 0/3] python3 follow-up patches for BaseTools
@ 2018-06-27 10:07 Gary Lin
2018-06-27 10:07 ` [PATCH 1/3] BaseTools: Remove the old python "not-equal" in DscBuildData.py Gary Lin
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Gary Lin @ 2018-06-27 10:07 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
This is the follow-up patch set for my previous python3 patch series:
https://lists.01.org/pipermail/edk2-devel/2018-June/026499.html
* A replacement of "<>" is missed in the previous series, and this is
fixed in this patch set.
* The previous patch to unify long and int caused the build error due to
the absence of long in TypeDict. The new implementation should be
compatible with both python2 and python3.
* Several bash scripts are modified to read PYTHON_DEFAULT to switch to
the python3 interpreter so that we can test the python3 compatibility
easily. Please note that BaseTools is still not ready, so any error
from python3 interpreter is expected.
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>
Gary Lin (3):
BaseTools: Remove the old python "not-equal" in DscBuildData.py
BaseTools: Unify long and int in Expression.py
BaseTools: Read the env variable PYTHON_DEFAULT
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 +++++-
BaseTools/Source/Python/Common/Expression.py | 6 ++++--
BaseTools/Source/Python/Workspace/DscBuildData.py | 2 +-
15 files changed, 70 insertions(+), 16 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] BaseTools: Remove the old python "not-equal" in DscBuildData.py
2018-06-27 10:07 [PATCH 0/3] python3 follow-up patches for BaseTools Gary Lin
@ 2018-06-27 10:07 ` 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
2 siblings, 0 replies; 6+ messages in thread
From: Gary Lin @ 2018-06-27 10:07 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Replace "<>" with "!=" to be compatible with python3.
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/Source/Python/Workspace/DscBuildData.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 06732e6fade4..5cc814185eb9 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -2108,7 +2108,7 @@ class DscBuildData(PlatformBuildClassObject):
Messages = StdErr
Messages = Messages.split('\n')
MessageGroup = []
- if returncode <>0:
+ if returncode != 0:
CAppBaseFileName = os.path.join(self.OutputPath, PcdValueInitName)
File = open (CAppBaseFileName + '.c', 'r')
FileData = File.readlines()
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] BaseTools: Unify long and int in Expression.py
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 ` Gary Lin
2018-06-27 10:07 ` [PATCH 3/3] BaseTools: Read the env variable PYTHON_DEFAULT Gary Lin
2 siblings, 0 replies; 6+ messages in thread
From: Gary Lin @ 2018-06-27 10:07 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Per PEP237(*), 'long' is unified with 'int' and removed from python3.
* To make the script compatible with both python2 and python3,
'type(0L)' is replaced with 'type(sys.maxsize + 1)'. In python2,
the number is 'long', while it's 'int' in python3. We can remove
the workaround after moving to python3 completely.
* long() is replaced with int() since int() returns a long when need.
(*) https://www.python.org/dev/peps/pep-0237/
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/Source/Python/Common/Expression.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index e1a2c155b7f3..51e8d2174a8f 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -20,6 +20,7 @@ from Misc import GuidStringToGuidStructureString, ParseFieldValue, IsFieldValueA
import Common.EdkLogger as EdkLogger
import copy
from Common.DataType import *
+import sys
ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].'
ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].'
@@ -254,7 +255,8 @@ class ValueExpression(BaseExpression):
Oprand2 = IntToStr(Oprand2)
TypeDict = {
type(0) : 0,
- type(0L) : 0,
+ # For python2 long type
+ type(sys.maxsize + 1) : 0,
type('') : 1,
type(True) : 2
}
@@ -892,7 +894,7 @@ class ValueExpressionEx(ValueExpression):
raise BadExpression('Type %s PCD Value Size is Larger than 8 byte' % self.PcdType)
else:
try:
- TmpValue = long(PcdValue)
+ TmpValue = int(PcdValue)
TmpList = []
if TmpValue.bit_length() == 0:
PcdValue = '{0x00}'
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] BaseTools: Read the env variable PYTHON_DEFAULT
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 ` Gary Lin
2018-07-06 0:46 ` Zhu, Yonghong
2 siblings, 1 reply; 6+ messages in thread
From: Gary Lin @ 2018-06-27 10:07 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] BaseTools: Read the env variable PYTHON_DEFAULT
2018-06-27 10:07 ` [PATCH 3/3] BaseTools: Read the env variable PYTHON_DEFAULT Gary Lin
@ 2018-07-06 0:46 ` Zhu, Yonghong
2018-07-06 1:49 ` Gary Lin
0 siblings, 1 reply; 6+ messages in thread
From: Zhu, Yonghong @ 2018-07-06 0:46 UTC (permalink / raw)
To: Gary Lin, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] BaseTools: Read the env variable PYTHON_DEFAULT
2018-07-06 0:46 ` Zhu, Yonghong
@ 2018-07-06 1:49 ` Gary Lin
0 siblings, 0 replies; 6+ messages in thread
From: Gary Lin @ 2018-07-06 1:49 UTC (permalink / raw)
To: Zhu, Yonghong; +Cc: edk2-devel@lists.01.org, Gao, Liming
On Fri, Jul 06, 2018 at 12:46:10AM +0000, Zhu, Yonghong wrote:
> 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.
>
Fair enough. I will keep the patch in my own branch and rebase it when
necessary. I have another patch set to adopt the absolute import and
will send them later. Hope this can help you for the python3 migration:)
Thanks,
Gary Lin
> 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
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-07-06 1:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2018-07-06 1:49 ` Gary Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox