aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar epoger <epoger@google.com>2014-07-10 09:03:23 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-10 09:03:26 -0700
commitfd429991e99d18cbb956f91b7c347440b39684c1 (patch)
treee80eba2001a49a0b9226c89b6fdd3820ff12c2e6 /tools
parent61b1436c224482611b864bff354b2664772b1b62 (diff)
import google-api-python-client using DEPS
BUG=skia:2641 R=jcgregorio@google.com Author: epoger@google.com Review URL: https://codereview.chromium.org/381933002
Diffstat (limited to 'tools')
-rwxr-xr-xtools/pyutils/gs_utils.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/tools/pyutils/gs_utils.py b/tools/pyutils/gs_utils.py
index 2659c03e63..fdf16adb82 100755
--- a/tools/pyutils/gs_utils.py
+++ b/tools/pyutils/gs_utils.py
@@ -7,20 +7,36 @@ Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
Utilities for accessing Google Cloud Storage.
-
-TODO(epoger): move this into tools/utils for broader use?
"""
# System-level imports
import os
import posixpath
import sys
+
+# Imports from third-party code
+TRUNK_DIRECTORY = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
+for import_subdir in ['google-api-python-client', 'httplib2', 'oauth2client',
+ 'uritemplate-py']:
+ import_dirpath = os.path.join(
+ TRUNK_DIRECTORY, 'third_party', 'externals', import_subdir)
+ if import_dirpath not in sys.path:
+ # We need to insert at the beginning of the path, to make sure that our
+ # imported versions are favored over others that might be in the path.
+ # Also, the google-api-python-client checkout contains an empty
+ # oauth2client directory, which will confuse things unless we insert
+ # our checked-out oauth2client in front of it in the path.
+ sys.path.insert(0, import_dirpath)
try:
- from apiclient.discovery import build as build_service
+ from googleapiclient.discovery import build as build_service
except ImportError:
- print ('Missing google-api-python-client. Please install it; directions '
+ # TODO(epoger): We are moving toward not needing any dependencies to be
+ # installed at a system level, but in the meanwhile, if developers run into
+ # trouble they can install those system-level dependencies to get unblocked.
+ print ('Missing dependencies of google-api-python-client. Please install '
+ 'google-api-python-client to get those dependencies; directions '
'can be found at https://developers.google.com/api-client-library/'
- 'python/start/installation')
+ 'python/start/installation . More details in http://skbug.com/2641 ')
raise
# Local imports