vpython3 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. # Export for other depot_tools scripts to re-use.
  34. export DEPOT_TOOLS_DIR="${DEPOT_TOOLS_DIR:-$(dirname "$0")}"
  35. export DEPOT_TOOLS_UNAME_S="${DEPOT_TOOLS_UNAME_S:-$(uname -s | tr '[:upper:]' '[:lower:]')}"
  36. # Don't write pyc files if running from a Cog workspace.
  37. if [[ "$(pwd)" == "/google/cog/"* ]]; then
  38. export PYTHONDONTWRITEBYTECODE=1
  39. fi
  40. source "${DEPOT_TOOLS_DIR}/cipd_bin_setup.sh"
  41. CIPD_ROOT=$(cipd_bin_setup) &> /dev/null
  42. # Don't pass this to the Python script as it might turn around and run commands
  43. # in other depot_tools dirs.
  44. base_dir="${DEPOT_TOOLS_DIR}"
  45. unset DEPOT_TOOLS_DIR
  46. case "${DEPOT_TOOLS_UNAME_S}" in
  47. mingw*|cygwin*)
  48. cmd.exe //c $0.bat "$@"
  49. ;;
  50. *)
  51. exec "$CIPD_ROOT/vpython3" "$@"
  52. ;;
  53. esac