Prevent PYTHONPATH from accumulatively growing.
After running "lunch" multiple times, the global variable
PYTHONPATH grows larger and larger with repetively content.
This patch is to prevent PYTHONPATH from prepending redundant path.
Bug: b/121110600
Test: $ source build/envsetup.sh && lunch
$ echo $PYTHONPATH | sed 's/:/\n/g'
$ lunch; lunch
$ echo $PYTHONPATH | sed 's/:/\n/g' # not growing.
Change-Id: Ifc36d071fb63bb1494bb0a94fdff477a41708c74
diff --git a/envsetup.sh b/envsetup.sh
index 561083d..44ae659 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -266,7 +266,14 @@
fi
export PATH=$ANDROID_BUILD_PATHS$PATH
- export PYTHONPATH=$T/development/python-packages:$PYTHONPATH
+
+ # out with the duplicate old
+ if [ -n $ANDROID_PYTHONPATH ]; then
+ export PYTHONPATH=${PYTHONPATH//$ANDROID_PYTHONPATH/}
+ fi
+ # and in with the new
+ export ANDROID_PYTHONPATH=$T/development/python-packages:
+ export PYTHONPATH=$ANDROID_PYTHONPATH$PYTHONPATH
export ANDROID_JAVA_HOME=$(get_abs_build_var ANDROID_JAVA_HOME)
export JAVA_HOME=$ANDROID_JAVA_HOME