2 # Copyright (c) 2012 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.
6 # This script is used to copy all dependencies into the local directory.
7 # The package of files can then be uploaded to App Engine.
13 SRC_DIR = os.path.join(sys.path[0], os.pardir, os.pardir, os.pardir, os.pardir,
15 THIRD_PARTY_DIR = os.path.join(SRC_DIR, 'third_party')
16 LOCAL_THIRD_PARTY_DIR = os.path.join(sys.path[0], 'third_party')
17 TOOLS_DIR = os.path.join(SRC_DIR, 'tools')
18 SCHEMA_COMPILER_FILES = ['memoize.py',
25 path = os.path.join(path, '__init__.py')
26 with open(os.path.join(path), 'w') as f:
27 os.utime(os.path.join(path), None)
29 def OnError(function, path, excinfo):
30 os.chmod(path, stat.S_IWUSR)
33 def CopyThirdParty(src, dest, files=None, make_init=True):
34 dest_path = os.path.join(LOCAL_THIRD_PARTY_DIR, dest)
36 shutil.copytree(src, dest_path)
41 os.makedirs(dest_path)
46 for filename in files:
47 shutil.copy(os.path.join(src, filename), os.path.join(dest_path, filename))
50 if os.path.isdir(LOCAL_THIRD_PARTY_DIR):
52 shutil.rmtree(LOCAL_THIRD_PARTY_DIR, False, OnError)
54 print('*-------------------------------------------------------------*\n'
55 '| If you are receiving an upload error, try removing |\n'
56 '| chrome/common/extensions/docs/server2/third_party manually. |\n'
57 '*-------------------------------------------------------------*\n')
60 CopyThirdParty(os.path.join(THIRD_PARTY_DIR, 'handlebar'), 'handlebar')
61 CopyThirdParty(os.path.join(THIRD_PARTY_DIR, 'markdown'), 'markdown',
63 CopyThirdParty(os.path.join(SRC_DIR, 'ppapi', 'generators'),
64 'json_schema_compiler')
65 CopyThirdParty(os.path.join(THIRD_PARTY_DIR, 'ply'),
66 os.path.join('json_schema_compiler', 'ply'))
67 CopyThirdParty(os.path.join(TOOLS_DIR, 'json_schema_compiler'),
68 'json_schema_compiler',
69 SCHEMA_COMPILER_FILES)
70 CopyThirdParty(os.path.join(TOOLS_DIR, 'json_comment_eater'),
71 'json_schema_compiler',
72 ['json_comment_eater.py'])
73 CopyThirdParty(os.path.join(THIRD_PARTY_DIR, 'simplejson'),
74 os.path.join('json_schema_compiler', 'simplejson'),
76 MakeInit(LOCAL_THIRD_PARTY_DIR)
78 CopyThirdParty(os.path.join(THIRD_PARTY_DIR, 'google_appengine_cloudstorage',
79 'cloudstorage'), 'cloudstorage')
81 # To be able to use the Handlebar class we need this import in __init__.py.
82 with open(os.path.join(LOCAL_THIRD_PARTY_DIR,
84 '__init__.py'), 'a') as f:
85 f.write('from handlebar import Handlebar\n')
87 if __name__ == '__main__':