| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse | 6 import argparse |
| 7 import contextlib | 7 import contextlib |
| 8 import glob | 8 import glob |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 requirements = [] | 147 requirements = [] |
| 148 # TODO(iannucci): Do this as a requirements.txt | 148 # TODO(iannucci): Do this as a requirements.txt |
| 149 for name, deps_entry in deps.iteritems(): | 149 for name, deps_entry in deps.iteritems(): |
| 150 if not deps_entry.get('implicit'): | 150 if not deps_entry.get('implicit'): |
| 151 requirements.append('%s==%s' % (name, deps_entry['version'])) | 151 requirements.append('%s==%s' % (name, deps_entry['version'])) |
| 152 subprocess.check_call( | 152 subprocess.check_call( |
| 153 [pip, 'install', '--no-index', '--download-cache', | 153 [pip, 'install', '--no-index', '--download-cache', |
| 154 os.path.join(ROOT, '.wheelcache'), '-f', ipath] + requirements) | 154 os.path.join(ROOT, '.wheelcache'), '-f', ipath] + requirements) |
| 155 | 155 |
| 156 | 156 |
| 157 def activate_env(env, deps, quiet): | 157 def activate_env(env, deps, quiet=False): |
| 158 if hasattr(sys, 'real_prefix'): | 158 if hasattr(sys, 'real_prefix'): |
| 159 LOGGER.error('Already activated environment!') | 159 LOGGER.error('Already activated environment!') |
| 160 return | 160 return |
| 161 | 161 |
| 162 if not quiet: | 162 if not quiet: |
| 163 print 'Activating environment: %r' % env | 163 print 'Activating environment: %r' % env |
| 164 assert isinstance(deps, dict) | 164 assert isinstance(deps, dict) |
| 165 | 165 |
| 166 manifest_path = os.path.join(env, 'manifest.pyl') | 166 manifest_path = os.path.join(env, 'manifest.pyl') |
| 167 cur_deps = read_deps(manifest_path) | 167 cur_deps = read_deps(manifest_path) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 opts = parser.parse_args(args) | 225 opts = parser.parse_args(args) |
| 226 | 226 |
| 227 deps = merge_deps(opts.deps_file) | 227 deps = merge_deps(opts.deps_file) |
| 228 activate_env(opts.env_path, deps, opts.quiet) | 228 activate_env(opts.env_path, deps, opts.quiet) |
| 229 | 229 |
| 230 | 230 |
| 231 if __name__ == '__main__': | 231 if __name__ == '__main__': |
| 232 logging.basicConfig() | 232 logging.basicConfig() |
| 233 LOGGER.setLevel(logging.DEBUG) | 233 LOGGER.setLevel(logging.DEBUG) |
| 234 sys.exit(main(sys.argv[1:])) | 234 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |