Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2014 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 | |
| 5 import ast | |
| 6 import contextlib | |
| 7 import os | |
| 8 import shutil | |
| 9 import sys | |
| 10 import tempfile | |
| 11 | |
| 12 | |
| 13 ROOT = os.path.dirname(os.path.abspath(__file__)) | |
| 14 WHEELHOUSE = os.path.join(ROOT, 'wheelhouse') | |
| 15 | |
| 16 print ROOT | |
|
Vadim Sh.
2014/07/22 18:43:24
remove
| |
| 17 | |
| 18 BUCKET = 'chrome-python-wheelhouse' | |
| 19 STORAGE_URL = 'https://www.googleapis.com/storage/v1/b/{}/o'.format(BUCKET) | |
| 20 OBJECT_URL = 'https://storage.googleapis.com/{}/{{}}#md5={{}}'.format(BUCKET) | |
| 21 | |
| 22 GIT_REPO = 'git+https://chromium.googlesource.com/infra/third_party/{}' | |
| 23 SOURCE_URL = 'gs://{}/sources/{{}}'.format(BUCKET) | |
| 24 WHEELS_URL = 'gs://{}/wheels/'.format(BUCKET) | |
| 25 | |
| 26 | |
| 27 def platform_tag(): | |
| 28 import platform | |
|
Vadim Sh.
2014/07/22 18:43:24
why lazy?
| |
| 29 plat_tag = '' | |
| 30 if sys.platform.startswith('linux'): | |
|
Vadim Sh.
2014/07/22 18:43:25
if sys.....:
return ...
return ''
| |
| 31 plat_tag = '_{0}_{1}'.format(*platform.linux_distribution()) | |
| 32 return plat_tag | |
| 33 | |
| 34 | |
| 35 def print_deps(deps, indent=1, with_implicit=True): | |
| 36 for dep, entry in deps.iteritems(): | |
| 37 if not with_implicit and entry.get('implicit'): | |
| 38 continue | |
| 39 print ' ' * indent + '%s: %r' % (dep, entry) | |
| 40 print | |
| 41 | |
| 42 | |
| 43 @contextlib.contextmanager | |
| 44 def tempdir(*args, **kwargs): | |
| 45 tdir = None | |
| 46 try: | |
| 47 tdir = tempfile.mkdtemp(*args, **kwargs) | |
| 48 yield tdir | |
| 49 finally: | |
| 50 if tdir: | |
| 51 shutil.rmtree(tdir, ignore_errors=True) | |
| 52 | |
| 53 | |
| 54 @contextlib.contextmanager | |
| 55 def tempname(*args, **kwargs): | |
| 56 tmp = None | |
| 57 try: | |
| 58 tmp = tempfile.mktemp(*args, **kwargs) | |
| 59 yield tmp | |
| 60 finally: | |
| 61 if tmp: | |
| 62 try: | |
| 63 os.unlink(tmp) | |
| 64 except OSError: | |
| 65 pass | |
| 66 | |
| 67 | |
| 68 def read_deps(path): | |
| 69 if os.path.exists(path): | |
| 70 with open(path, 'rb') as f: | |
| 71 return ast.literal_eval(f.read()) | |
| OLD | NEW |