blob: 63dbf5441eda2c6440f28b5721178782de146d08 [file] [log] [blame]
Robert Nagy059f26b2019-05-10 14:58:03 +00001#!/usr/bin/env bash
Sergey Berezin6fee2672017-05-01 15:31:16 -07002
Robert Iannuccifc40ad22018-02-20 16:49:12 -08003# Copyright 2018 The Chromium Authors. All rights reserved.
Sergey Berezin6fee2672017-05-01 15:31:16 -07004# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
Robert Iannuccifc40ad22018-02-20 16:49:12 -08007if [[ $VPYTHON_BYPASS == "manually managed python not supported by chrome operations" ]]
8then
9 NEWARGS=()
10 while [[ $# -gt 0 ]]
11 do
12 case "$1" in
13 -vpython-tool*) # these tools all do something vpython related and quit
14 exit 0
15 ;;
16 -vpython*=*) # delete any vpython-specific flag (w/ attached argument)
17 shift
18 ;;
19 -vpython*) # delete any vpython-specific flag (w/ separate argument)
20 shift
21 shift
22 ;;
23 --) # stop parsing
24 NEWARGS+=( "$@" )
25 break
26 ;;
27 *) # regular arg
28 NEWARGS+=( "$1" )
29 shift
30 ;;
31 esac
32 done
33 exec "python" "${NEWARGS[@]}"
34fi
35
36
John Budorick6ec8b512019-11-19 15:49:52 +000037base_dir=$(dirname "$0")
Sergey Berezin6fee2672017-05-01 15:31:16 -070038
John Budorick6ec8b512019-11-19 15:49:52 +000039source "$base_dir/cipd_bin_setup.sh"
Dan Jacques5aeeb722017-07-28 15:22:25 +020040cipd_bin_setup &> /dev/null
Sergey Berezin6fee2672017-05-01 15:31:16 -070041
Mike Frysinger5260b2b2021-03-30 02:09:47 +000042# If Python bootstrapping is not disabled, make sure Python has been
43# bootstrapped and add it to the front of PATH.
44if [[ $(uname -s) = MINGW* || $(uname -s) = CYGWIN* ]]; then
45 cmd.exe //c $0.bat "$@"
46elif [[ $DEPOT_TOOLS_BOOTSTRAP_PYTHON3 != 0 ]]; then
47 if [[ ! -e "$base_dir/python_bin_reldir.txt" ]]; then
48 source "$base_dir/bootstrap_python3"
49 bootstrap_python3
50 fi
51 PYTHON_BIN_RELDIR="$base_dir/$(cat "$base_dir/python_bin_reldir.txt" | xargs echo)"
52 exec "$base_dir/.cipd_bin/vpython" -vpython-interpreter "$PYTHON_BIN_RELDIR/python" "$@"
53else
54 exec "$base_dir/.cipd_bin/vpython" "$@"
55fi