vpython 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. # Copyright 2018 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. # See revert instructions in cipd_manifest.txt
  6. if [[ $VPYTHON_BYPASS == "manually managed python not supported by chrome operations" ]]
  7. then
  8. NEWARGS=()
  9. while [[ $# -gt 0 ]]
  10. do
  11. case "$1" in
  12. -vpython-tool*) # these tools all do something vpython related and quit
  13. exit 0
  14. ;;
  15. -vpython*=*) # delete any vpython-specific flag (w/ attached argument)
  16. shift
  17. ;;
  18. -vpython*) # delete any vpython-specific flag (w/ separate argument)
  19. shift
  20. shift
  21. ;;
  22. --) # stop parsing
  23. NEWARGS+=( "$@" )
  24. break
  25. ;;
  26. *) # regular arg
  27. NEWARGS+=( "$1" )
  28. shift
  29. ;;
  30. esac
  31. done
  32. exec "python" "${NEWARGS[@]}"
  33. fi
  34. base_dir=$(dirname "$0")
  35. source "$base_dir/cipd_bin_setup.sh"
  36. cipd_bin_setup &> /dev/null
  37. # If Python bootstrapping is not disabled, make sure Python has been
  38. # bootstrapped and add it to the front of PATH.
  39. if [[ $(uname -s) = MINGW* || $(uname -s) = CYGWIN* ]]; then
  40. cmd.exe //c $0.bat "$@"
  41. elif [[ $DEPOT_TOOLS_BOOTSTRAP_PYTHON3 != 0 ]]; then
  42. if [[ ! -e "$base_dir/python_bin_reldir.txt" ]]; then
  43. source "$base_dir/bootstrap_python3"
  44. bootstrap_python3
  45. fi
  46. PYTHON_BIN_RELDIR="$base_dir/$(cat "$base_dir/python_bin_reldir.txt" | xargs echo)"
  47. exec "$base_dir/.cipd_bin/vpython" -vpython-interpreter "$PYTHON_BIN_RELDIR/python" "$@"
  48. else
  49. exec "$base_dir/.cipd_bin/vpython" "$@"
  50. fi