From a51523074908db88dd2bc4dc0779979c1c12df44 Mon Sep 17 00:00:00 2001
From: Evan Lloyd <evan.lloyd@arm.com>
Date: Fri, 17 Jan 2014 18:46:58 +0000
Subject: [PATCH 3/4] BaseTools/toolsetup.bat: Basetools corrupts PYTHONPATH

The PYTHONPATH variable is used globally by Python, but is corrupted by toolsetup.bat
that means that downstream invocation of python scripts may fail as they will
not be able to find library modules.
The basic fix is to use set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
---
 BaseTools/toolsetup.bat | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat
index 24bf76c..71c3811 100755
--- a/BaseTools/toolsetup.bat
+++ b/BaseTools/toolsetup.bat
@@ -246,7 +246,8 @@ goto end
   )
   set PATH=%BASE_TOOLS_PATH%\Bin\Win32;%PATH%
 
-  set PYTHONPATH=%BASE_TOOLS_PATH%\Source\Python
+  set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python
+  set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%
 
   if not defined PYTHON_HOME (
     if defined PYTHONHOME (
@@ -279,8 +280,9 @@ goto end
       echo !!! WARNING !!! Will not be able to compile Python programs to .exe
       echo Will setup environment to run Python scripts directly.
       echo.
-      set PYTHONPATH=%BASE_TOOLS_PATH%\Source\Python
-      set PATH=%PYTHONPATH%\build;%PYTHONPATH%\GenFds;%PYTHONPATH%\Trim;%PATH%
+      set PATH=%BASETOOLS_PYTHON_SOURCE%\Trim;%PATH%
+      set PATH=%BASETOOLS_PYTHON_SOURCE%\GenFds;%PATH%
+      set PATH=%BASETOOLS_PYTHON_SOURCE%\build;%PATH%
       set PATHEXT=%PATHEXT%;.py
     )
   )
-- 
1.8.5

