• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2015 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import os
6import sys
7
8_CATAPULT_PATH = os.path.abspath(
9    os.path.join(os.path.dirname(__file__), '..', '..'))
10
11# Directories in catapult/third_party required by dashboard.
12THIRD_PARTY_LIBRARIES = [
13    'apiclient',
14    'beautifulsoup4',
15    'graphy',
16    'mapreduce',
17    'mock',
18    'pipeline',
19    'uritemplate',
20    'webtest',
21    'flot',
22    'jquery',
23    'polymer',
24]
25
26# Libraries bundled with the App Engine SDK.
27THIRD_PARTY_LIBRARIES_IN_SDK = [
28    'httplib2',
29    'oauth2client',
30    'six',
31]
32
33# Files and directories in catapult/dashboard.
34DASHBOARD_FILES = [
35    'appengine_config.py',
36    'app.yaml',
37    'dashboard',
38    'index.yaml',
39    'mapreduce.yaml',
40    'queue.yaml',
41]
42
43
44def PathsForDeployment():
45  """Returns a list of paths to things required for deployment.
46
47  This includes both Python libraries that are required, and also
48  other files, such as config files.
49
50  This list is used when building a temporary deployment directory;
51  each of the items in this list will have a corresponding file or
52  directory with the same basename in the deployment directory.
53  """
54  paths = []
55  paths.extend(_CatapultThirdPartyLibraryPaths())
56  for p in _AllSdkThirdPartyLibraryPaths():
57    if os.path.basename(p) in THIRD_PARTY_LIBRARIES_IN_SDK:
58      paths.append(p)
59  for name in DASHBOARD_FILES:
60    paths.append(os.path.join(_CATAPULT_PATH, 'dashboard', name))
61  return paths
62
63
64def ExtraPythonLibraryPaths():
65  """Returns a list of Python library paths required for dashboard tests."""
66  paths = []
67  paths.append(os.path.join(_CATAPULT_PATH, 'dashboard'))
68  paths.extend(_AllSdkThirdPartyLibraryPaths())
69  paths.extend(_CatapultThirdPartyLibraryPaths())
70  return paths
71
72
73def _AllSdkThirdPartyLibraryPaths():
74  """Returns a list of all third party library paths from the SDK."""
75  try:
76    import dev_appserver
77  except ImportError:
78    # TODO(qyearsley): Put the App Engine SDK in the path with the
79    # binary dependency manager.
80    # https://github.com/catapult-project/catapult/issues/2135
81    print 'This script requires the App Engine SDK to be in PYTHONPATH.'
82    sys.exit(1)
83  return dev_appserver.EXTRA_PATHS
84
85
86def _CatapultThirdPartyLibraryPaths():
87  """Returns a list of required third-party libraries in catapult."""
88  paths = []
89  for library in THIRD_PARTY_LIBRARIES:
90    paths.append(os.path.join(_CATAPULT_PATH, 'third_party', library))
91  return paths
92