[gsutil] run through "vpython" (2)
Run "gsutil" through "vpython". This ensures that the package set
accompanying it is completely controlled. This is notably important on
GCE instances, which "gsutil" expects to supply a
"google_compute_engine" package.
BUG=chromium:741001
TEST=local
- Ran `gsutil cp` on 64-bit Linux machine, seems to work.
- Ran `gsutil cp` on GCE instance, seems to work.
This is a reland of 23836a643f480b21e91340f2f9845619ebf6f9c4.
Change-Id: If87261abd505ef77f95b3c70b6bd23f3e798b41d
Reviewed-on: https://chromium-review.googlesource.com/656565
Reviewed-by: Nodir Turakulov <nodir@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Daniel Jacques <dnj@chromium.org>
diff --git a/gsutil.py b/gsutil.py
index d57cafb..eb339bc 100755
--- a/gsutil.py
+++ b/gsutil.py
@@ -29,6 +29,9 @@
DEFAULT_FALLBACK_GSUTIL = os.path.join(
THIS_DIR, 'third_party', 'gsutil', 'gsutil')
+IS_WINDOWS = os.name == 'nt'
+
+
class InvalidGsutilError(Exception):
pass
@@ -126,8 +129,17 @@
else:
gsutil_bin = fallback
disable_update = ['-o', 'GSUtil:software_update_check_period=0']
- cmd = [sys.executable, gsutil_bin] + disable_update + args
- return subprocess.call(cmd)
+
+ # Run "gsutil" through "vpython". We need to do this because on GCE instances,
+ # expectations are made about Python having access to "google-compute-engine"
+ # and "boto" packages that are not met with non-system Python (e.g., bundles).
+ cmd = [
+ 'vpython',
+ '-vpython-spec', os.path.join(THIS_DIR, 'gsutil.vpython'),
+ '--',
+ gsutil_bin
+ ] + disable_update + args
+ return subprocess.call(cmd, shell=IS_WINDOWS)
def parse_args():