Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: bootstrap/util.py

Issue 381043002: Add a virtualenv-based python bootstrapping service to infra. (Closed) Base URL: https://chromium.googlesource.com/infra/infra@master
Patch Set: Address comments, add warning while building on Ubuntu Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « bootstrap/ingest_source.py ('k') | infra/ext/__init__.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 platform
9 import shutil
10 import sys
11 import tempfile
12
13
14 ROOT = os.path.dirname(os.path.abspath(__file__))
15 WHEELHOUSE = os.path.join(ROOT, 'wheelhouse')
16
17 BUCKET = 'chrome-python-wheelhouse'
18 STORAGE_URL = 'https://www.googleapis.com/storage/v1/b/{}/o'.format(BUCKET)
19 OBJECT_URL = 'https://storage.googleapis.com/{}/{{}}#md5={{}}'.format(BUCKET)
20
21 GIT_REPO = 'git+https://chromium.googlesource.com/infra/third_party/{}'
22 SOURCE_URL = 'gs://{}/sources/{{}}'.format(BUCKET)
23 WHEELS_URL = 'gs://{}/wheels/'.format(BUCKET)
24
25
26 def platform_tag():
27 if sys.platform.startswith('linux'):
28 return '_{0}_{1}'.format(*platform.linux_distribution())
29 return ''
30
31
32 def print_deps(deps, indent=1, with_implicit=True):
33 for dep, entry in deps.iteritems():
34 if not with_implicit and entry.get('implicit'):
35 continue
36 print ' ' * indent + '%s: %r' % (dep, entry)
37 print
38
39
40 @contextlib.contextmanager
41 def tempdir(*args, **kwargs):
42 tdir = None
43 try:
44 tdir = tempfile.mkdtemp(*args, **kwargs)
45 yield tdir
46 finally:
47 if tdir:
48 shutil.rmtree(tdir, ignore_errors=True)
49
50
51 @contextlib.contextmanager
52 def tempname(*args, **kwargs):
53 tmp = None
54 try:
55 tmp = tempfile.mktemp(*args, **kwargs)
56 yield tmp
57 finally:
58 if tmp:
59 try:
60 os.unlink(tmp)
61 except OSError:
62 pass
63
64
65 def read_deps(path):
66 if os.path.exists(path):
67 with open(path, 'rb') as f:
68 return ast.literal_eval(f.read())
OLDNEW
« no previous file with comments | « bootstrap/ingest_source.py ('k') | infra/ext/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698