public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools/PosixLike: honor pre-set PYTHONPATH
@ 2018-03-14 10:54 Laszlo Ersek
  2018-03-20 15:28 ` Laszlo Ersek
  2018-03-21  2:22 ` Gao, Liming
  0 siblings, 2 replies; 4+ messages in thread
From: Laszlo Ersek @ 2018-03-14 10:54 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Liming Gao, Yonghong Zhu

Utilities written in Python may depend on external (preinstalled) Python
packages; for example, Ecc depends on "antlr_python_runtime-3.0.1". Such
packages need not be installed system-wide, as long as they are reachable
through PYTHONPATH. Therefore we shouldn't overwrite the user's PYTHONPATH
with "BaseTools/Source/Python"; instead, we should prepend the latter to
the former.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=896
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
    Repo:   https://github.com/lersek/edk2.git
    Branch: pythonpath

 BaseTools/BinWrappers/PosixLike/BPDG                      | 2 +-
 BaseTools/BinWrappers/PosixLike/Ecc                       | 2 +-
 BaseTools/BinWrappers/PosixLike/GenDepex                  | 2 +-
 BaseTools/BinWrappers/PosixLike/GenFds                    | 2 +-
 BaseTools/BinWrappers/PosixLike/GenPatchPcdTable          | 2 +-
 BaseTools/BinWrappers/PosixLike/PatchPcdValue             | 2 +-
 BaseTools/BinWrappers/PosixLike/Pkcs7Sign                 | 2 +-
 BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys | 2 +-
 BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign         | 2 +-
 BaseTools/BinWrappers/PosixLike/TargetTool                | 2 +-
 BaseTools/BinWrappers/PosixLike/Trim                      | 2 +-
 BaseTools/BinWrappers/PosixLike/UPT                       | 2 +-
 BaseTools/BinWrappers/PosixLike/build                     | 2 +-
 13 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/BaseTools/BinWrappers/PosixLike/BPDG b/BaseTools/BinWrappers/PosixLike/BPDG
index 214d88fff1b1..01ae23ddeb4f 100755
--- a/BaseTools/BinWrappers/PosixLike/BPDG
+++ b/BaseTools/BinWrappers/PosixLike/BPDG
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
diff --git a/BaseTools/BinWrappers/PosixLike/Ecc b/BaseTools/BinWrappers/PosixLike/Ecc
index 214d88fff1b1..01ae23ddeb4f 100755
--- a/BaseTools/BinWrappers/PosixLike/Ecc
+++ b/BaseTools/BinWrappers/PosixLike/Ecc
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
diff --git a/BaseTools/BinWrappers/PosixLike/GenDepex b/BaseTools/BinWrappers/PosixLike/GenDepex
index bdb6722a1f84..dad174788bc3 100755
--- a/BaseTools/BinWrappers/PosixLike/GenDepex
+++ b/BaseTools/BinWrappers/PosixLike/GenDepex
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/AutoGen/$cmd.py" "$@"
diff --git a/BaseTools/BinWrappers/PosixLike/GenFds b/BaseTools/BinWrappers/PosixLike/GenFds
index 214d88fff1b1..01ae23ddeb4f 100755
--- a/BaseTools/BinWrappers/PosixLike/GenFds
+++ b/BaseTools/BinWrappers/PosixLike/GenFds
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
diff --git a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
index 214d88fff1b1..01ae23ddeb4f 100755
--- a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
+++ b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
diff --git a/BaseTools/BinWrappers/PosixLike/PatchPcdValue b/BaseTools/BinWrappers/PosixLike/PatchPcdValue
index 214d88fff1b1..01ae23ddeb4f 100755
--- a/BaseTools/BinWrappers/PosixLike/PatchPcdValue
+++ b/BaseTools/BinWrappers/PosixLike/PatchPcdValue
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
diff --git a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign
index 214d88fff1b1..01ae23ddeb4f 100755
--- a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign
+++ b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
index 2cddde9d4f0b..1bc1054a3452 100755
--- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
+++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/Rsa2048Sha256Sign/$cmd.py" "$@"
diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
index 214d88fff1b1..01ae23ddeb4f 100755
--- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
+++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
diff --git a/BaseTools/BinWrappers/PosixLike/TargetTool b/BaseTools/BinWrappers/PosixLike/TargetTool
index 214d88fff1b1..01ae23ddeb4f 100755
--- a/BaseTools/BinWrappers/PosixLike/TargetTool
+++ b/BaseTools/BinWrappers/PosixLike/TargetTool
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
diff --git a/BaseTools/BinWrappers/PosixLike/Trim b/BaseTools/BinWrappers/PosixLike/Trim
index 7cac4f7c4fff..6c8dde5bec3e 100755
--- a/BaseTools/BinWrappers/PosixLike/Trim
+++ b/BaseTools/BinWrappers/PosixLike/Trim
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 exe=$(basename "$full_cmd")
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/$exe/$exe.py" "$@"
diff --git a/BaseTools/BinWrappers/PosixLike/UPT b/BaseTools/BinWrappers/PosixLike/UPT
index 214d88fff1b1..01ae23ddeb4f 100755
--- a/BaseTools/BinWrappers/PosixLike/UPT
+++ b/BaseTools/BinWrappers/PosixLike/UPT
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
diff --git a/BaseTools/BinWrappers/PosixLike/build b/BaseTools/BinWrappers/PosixLike/build
index 214d88fff1b1..01ae23ddeb4f 100755
--- a/BaseTools/BinWrappers/PosixLike/build
+++ b/BaseTools/BinWrappers/PosixLike/build
@@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
 dir=$(dirname "$full_cmd")
 cmd=${full_cmd##*/}
 
-export PYTHONPATH="$dir/../../Source/Python"
+export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
 exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
-- 
2.14.1.3.gb7cf6e02401b



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

* Re: [PATCH] BaseTools/PosixLike: honor pre-set PYTHONPATH
  2018-03-14 10:54 [PATCH] BaseTools/PosixLike: honor pre-set PYTHONPATH Laszlo Ersek
@ 2018-03-20 15:28 ` Laszlo Ersek
  2018-03-21  2:22 ` Gao, Liming
  1 sibling, 0 replies; 4+ messages in thread
From: Laszlo Ersek @ 2018-03-20 15:28 UTC (permalink / raw)
  To: edk2-devel-01; +Cc: Liming Gao, Zhu, Yonghong

Hello Liming, Yonghong,

On 03/14/18 11:54, Laszlo Ersek wrote:
> Utilities written in Python may depend on external (preinstalled) Python
> packages; for example, Ecc depends on "antlr_python_runtime-3.0.1". Such
> packages need not be installed system-wide, as long as they are reachable
> through PYTHONPATH. Therefore we shouldn't overwrite the user's PYTHONPATH
> with "BaseTools/Source/Python"; instead, we should prepend the latter to
> the former.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=896
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
> 
> Notes:
>     Repo:   https://github.com/lersek/edk2.git
>     Branch: pythonpath

Ping -- looks like this patch was missed; can you guys please review it?

Thanks,
Laszlo

>  BaseTools/BinWrappers/PosixLike/BPDG                      | 2 +-
>  BaseTools/BinWrappers/PosixLike/Ecc                       | 2 +-
>  BaseTools/BinWrappers/PosixLike/GenDepex                  | 2 +-
>  BaseTools/BinWrappers/PosixLike/GenFds                    | 2 +-
>  BaseTools/BinWrappers/PosixLike/GenPatchPcdTable          | 2 +-
>  BaseTools/BinWrappers/PosixLike/PatchPcdValue             | 2 +-
>  BaseTools/BinWrappers/PosixLike/Pkcs7Sign                 | 2 +-
>  BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys | 2 +-
>  BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign         | 2 +-
>  BaseTools/BinWrappers/PosixLike/TargetTool                | 2 +-
>  BaseTools/BinWrappers/PosixLike/Trim                      | 2 +-
>  BaseTools/BinWrappers/PosixLike/UPT                       | 2 +-
>  BaseTools/BinWrappers/PosixLike/build                     | 2 +-
>  13 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/BaseTools/BinWrappers/PosixLike/BPDG b/BaseTools/BinWrappers/PosixLike/BPDG
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/BPDG
> +++ b/BaseTools/BinWrappers/PosixLike/BPDG
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/Ecc b/BaseTools/BinWrappers/PosixLike/Ecc
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/Ecc
> +++ b/BaseTools/BinWrappers/PosixLike/Ecc
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/GenDepex b/BaseTools/BinWrappers/PosixLike/GenDepex
> index bdb6722a1f84..dad174788bc3 100755
> --- a/BaseTools/BinWrappers/PosixLike/GenDepex
> +++ b/BaseTools/BinWrappers/PosixLike/GenDepex
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/AutoGen/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/GenFds b/BaseTools/BinWrappers/PosixLike/GenFds
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/GenFds
> +++ b/BaseTools/BinWrappers/PosixLike/GenFds
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
> +++ b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/PatchPcdValue b/BaseTools/BinWrappers/PosixLike/PatchPcdValue
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/PatchPcdValue
> +++ b/BaseTools/BinWrappers/PosixLike/PatchPcdValue
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign
> +++ b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
> index 2cddde9d4f0b..1bc1054a3452 100755
> --- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
> +++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/Rsa2048Sha256Sign/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
> +++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/TargetTool b/BaseTools/BinWrappers/PosixLike/TargetTool
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/TargetTool
> +++ b/BaseTools/BinWrappers/PosixLike/TargetTool
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/Trim b/BaseTools/BinWrappers/PosixLike/Trim
> index 7cac4f7c4fff..6c8dde5bec3e 100755
> --- a/BaseTools/BinWrappers/PosixLike/Trim
> +++ b/BaseTools/BinWrappers/PosixLike/Trim
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  exe=$(basename "$full_cmd")
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$exe/$exe.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/UPT b/BaseTools/BinWrappers/PosixLike/UPT
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/UPT
> +++ b/BaseTools/BinWrappers/PosixLike/UPT
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/build b/BaseTools/BinWrappers/PosixLike/build
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/build
> +++ b/BaseTools/BinWrappers/PosixLike/build
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
>  
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> 



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

* Re: [PATCH] BaseTools/PosixLike: honor pre-set PYTHONPATH
  2018-03-14 10:54 [PATCH] BaseTools/PosixLike: honor pre-set PYTHONPATH Laszlo Ersek
  2018-03-20 15:28 ` Laszlo Ersek
@ 2018-03-21  2:22 ` Gao, Liming
  2018-03-21 14:56   ` Laszlo Ersek
  1 sibling, 1 reply; 4+ messages in thread
From: Gao, Liming @ 2018-03-21  2:22 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel-01

The change is good. 

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Wednesday, March 14, 2018 6:54 PM
> To: edk2-devel-01 <edk2-devel@lists.01.org>
> Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
> Subject: [PATCH] BaseTools/PosixLike: honor pre-set PYTHONPATH
> 
> Utilities written in Python may depend on external (preinstalled) Python
> packages; for example, Ecc depends on "antlr_python_runtime-3.0.1". Such
> packages need not be installed system-wide, as long as they are reachable
> through PYTHONPATH. Therefore we shouldn't overwrite the user's PYTHONPATH
> with "BaseTools/Source/Python"; instead, we should prepend the latter to
> the former.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=896
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
> 
> Notes:
>     Repo:   https://github.com/lersek/edk2.git
>     Branch: pythonpath
> 
>  BaseTools/BinWrappers/PosixLike/BPDG                      | 2 +-
>  BaseTools/BinWrappers/PosixLike/Ecc                       | 2 +-
>  BaseTools/BinWrappers/PosixLike/GenDepex                  | 2 +-
>  BaseTools/BinWrappers/PosixLike/GenFds                    | 2 +-
>  BaseTools/BinWrappers/PosixLike/GenPatchPcdTable          | 2 +-
>  BaseTools/BinWrappers/PosixLike/PatchPcdValue             | 2 +-
>  BaseTools/BinWrappers/PosixLike/Pkcs7Sign                 | 2 +-
>  BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys | 2 +-
>  BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign         | 2 +-
>  BaseTools/BinWrappers/PosixLike/TargetTool                | 2 +-
>  BaseTools/BinWrappers/PosixLike/Trim                      | 2 +-
>  BaseTools/BinWrappers/PosixLike/UPT                       | 2 +-
>  BaseTools/BinWrappers/PosixLike/build                     | 2 +-
>  13 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/BaseTools/BinWrappers/PosixLike/BPDG b/BaseTools/BinWrappers/PosixLike/BPDG
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/BPDG
> +++ b/BaseTools/BinWrappers/PosixLike/BPDG
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/Ecc b/BaseTools/BinWrappers/PosixLike/Ecc
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/Ecc
> +++ b/BaseTools/BinWrappers/PosixLike/Ecc
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/GenDepex b/BaseTools/BinWrappers/PosixLike/GenDepex
> index bdb6722a1f84..dad174788bc3 100755
> --- a/BaseTools/BinWrappers/PosixLike/GenDepex
> +++ b/BaseTools/BinWrappers/PosixLike/GenDepex
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/AutoGen/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/GenFds b/BaseTools/BinWrappers/PosixLike/GenFds
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/GenFds
> +++ b/BaseTools/BinWrappers/PosixLike/GenFds
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
> +++ b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/PatchPcdValue b/BaseTools/BinWrappers/PosixLike/PatchPcdValue
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/PatchPcdValue
> +++ b/BaseTools/BinWrappers/PosixLike/PatchPcdValue
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign
> +++ b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
> b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
> index 2cddde9d4f0b..1bc1054a3452 100755
> --- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
> +++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/Rsa2048Sha256Sign/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
> +++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/TargetTool b/BaseTools/BinWrappers/PosixLike/TargetTool
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/TargetTool
> +++ b/BaseTools/BinWrappers/PosixLike/TargetTool
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/Trim b/BaseTools/BinWrappers/PosixLike/Trim
> index 7cac4f7c4fff..6c8dde5bec3e 100755
> --- a/BaseTools/BinWrappers/PosixLike/Trim
> +++ b/BaseTools/BinWrappers/PosixLike/Trim
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  exe=$(basename "$full_cmd")
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$exe/$exe.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/UPT b/BaseTools/BinWrappers/PosixLike/UPT
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/UPT
> +++ b/BaseTools/BinWrappers/PosixLike/UPT
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> diff --git a/BaseTools/BinWrappers/PosixLike/build b/BaseTools/BinWrappers/PosixLike/build
> index 214d88fff1b1..01ae23ddeb4f 100755
> --- a/BaseTools/BinWrappers/PosixLike/build
> +++ b/BaseTools/BinWrappers/PosixLike/build
> @@ -10,5 +10,5 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
> -export PYTHONPATH="$dir/../../Source/Python"
> +export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
>  exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
> --
> 2.14.1.3.gb7cf6e02401b



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

* Re: [PATCH] BaseTools/PosixLike: honor pre-set PYTHONPATH
  2018-03-21  2:22 ` Gao, Liming
@ 2018-03-21 14:56   ` Laszlo Ersek
  0 siblings, 0 replies; 4+ messages in thread
From: Laszlo Ersek @ 2018-03-21 14:56 UTC (permalink / raw)
  To: Gao, Liming, edk2-devel-01

On 03/21/18 03:22, Gao, Liming wrote:
> The change is good. 
> 
> Reviewed-by: Liming Gao <liming.gao@intel.com>

Thank you, Liming; commit b12b2c74a3fb.

Laszlo


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

end of thread, other threads:[~2018-03-21 14:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-14 10:54 [PATCH] BaseTools/PosixLike: honor pre-set PYTHONPATH Laszlo Ersek
2018-03-20 15:28 ` Laszlo Ersek
2018-03-21  2:22 ` Gao, Liming
2018-03-21 14:56   ` Laszlo Ersek

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