vpython3 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env bash
  2. # Copyright 2019 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. if [[ $VPYTHON_BYPASS == "manually managed python not supported by chrome operations" ]]
  6. then
  7. NEWARGS=()
  8. while [[ $# -gt 0 ]]
  9. do
  10. case "$1" in
  11. -vpython-tool*) # these tools all do something vpython related and quit
  12. exit 0
  13. ;;
  14. -vpython*=*) # delete any vpython-specific flag (w/ attached argument)
  15. shift
  16. ;;
  17. -vpython*) # delete any vpython-specific flag (w/ separate argument)
  18. shift
  19. shift
  20. ;;
  21. --) # stop parsing
  22. NEWARGS+=( "$@" )
  23. break
  24. ;;
  25. *) # regular arg
  26. NEWARGS+=( "$1" )
  27. shift
  28. ;;
  29. esac
  30. done
  31. exec "python3" "${NEWARGS[@]}"
  32. fi
  33. base_dir=$(dirname "$0")
  34. source "$base_dir/cipd_bin_setup.sh"
  35. cipd_bin_setup &> /dev/null
  36. # If Python bootstrapping is not disabled, make sure Python has been
  37. # bootstrapped and add it to the front of PATH.
  38. if [[ $MINGW != 0 && $DEPOT_TOOLS_BOOTSTRAP_PYTHON3 != 0 ]]; then
  39. if [[ ! -e $base_dir/python3_bin_reldir.txt ]]; then
  40. source "$base_dir/bootstrap_python3"
  41. bootstrap_python3
  42. fi
  43. PYTHON3_BIN_RELDIR="$base_dir/$(cat $base_dir/python3_bin_reldir.txt | xargs echo)"
  44. PATH="$PYTHON3_BIN_RELDIR":"$PYTHON3_BIN_RELDIR/Scripts":"$PATH"
  45. fi
  46. exec "$base_dir/.cipd_bin/vpython3" "$@"