Chromium Code Reviews| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 pip = os.path.join(sys.prefix, bin_dir, 'pip') | 144 pip = os.path.join(sys.prefix, bin_dir, 'pip') |
| 145 | 145 |
| 146 links = get_links(deps) | 146 links = get_links(deps) |
| 147 with html_index(links) as ipath: | 147 with html_index(links) as ipath: |
| 148 requirements = [] | 148 requirements = [] |
| 149 # TODO(iannucci): Do this as a requirements.txt | 149 # TODO(iannucci): Do this as a requirements.txt |
| 150 for name, deps_entry in deps.iteritems(): | 150 for name, deps_entry in deps.iteritems(): |
| 151 if not deps_entry.get('implicit'): | 151 if not deps_entry.get('implicit'): |
| 152 requirements.append('%s==%s' % (name, deps_entry['version'])) | 152 requirements.append('%s==%s' % (name, deps_entry['version'])) |
| 153 subprocess.check_call( | 153 subprocess.check_call( |
| 154 [pip, 'install', '--no-index', '--download-cache', | 154 [pip, 'install', '--no-index', '-f', ipath] + requirements) |
|
Vadim Sh.
2016/06/08 00:26:30
update README.md not to mention .wheelcache
nodir
2016/06/08 00:46:05
Done.
| |
| 155 os.path.join(ROOT, '.wheelcache'), '-f', ipath] + requirements) | |
| 156 | 155 |
| 157 | 156 |
| 158 def activate_env(env, deps, quiet=False): | 157 def activate_env(env, deps, quiet=False): |
| 159 if hasattr(sys, 'real_prefix'): | 158 if hasattr(sys, 'real_prefix'): |
| 160 LOGGER.error('Already activated environment!') | 159 LOGGER.error('Already activated environment!') |
| 161 return | 160 return |
| 162 | 161 |
| 163 if not quiet: | 162 if not quiet: |
| 164 print 'Activating environment: %r' % env | 163 print 'Activating environment: %r' % env |
| 165 assert isinstance(deps, dict) | 164 assert isinstance(deps, dict) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 os.environ.pop('PYTHONPATH', None) | 212 os.environ.pop('PYTHONPATH', None) |
| 214 bin_dir = 'Scripts' if sys.platform.startswith('win') else 'bin' | 213 bin_dir = 'Scripts' if sys.platform.startswith('win') else 'bin' |
| 215 activate_this = os.path.join(env, bin_dir, 'activate_this.py') | 214 activate_this = os.path.join(env, bin_dir, 'activate_this.py') |
| 216 execfile(activate_this, dict(__file__=activate_this)) | 215 execfile(activate_this, dict(__file__=activate_this)) |
| 217 | 216 |
| 218 if cur_deps is None: | 217 if cur_deps is None: |
| 219 if not quiet: | 218 if not quiet: |
| 220 print ' Installing deps' | 219 print ' Installing deps' |
| 221 print_deps(deps, indent=2, with_implicit=False) | 220 print_deps(deps, indent=2, with_implicit=False) |
| 222 install(deps) | 221 install(deps) |
| 223 virtualenv.make_environment_relocatable(env) | 222 virtualenv.make_environment_relocatable(env) |
|
Vadim Sh.
2016/06/08 00:26:30
I hope this didn't break. If it did, infra_python
nodir
2016/06/08 00:46:05
I tried `build.py infra_python` with this patch ap
Vadim Sh.
2016/06/08 00:48:38
Install it (using cipd pkg-deploy) into some path,
nodir
2016/06/17 02:18:53
$ cipd pkg-deploy -root infra_python infra_python.
| |
| 224 with open(manifest_path, 'wb') as f: | 223 with open(manifest_path, 'wb') as f: |
| 225 f.write(repr(deps) + '\n') | 224 f.write(repr(deps) + '\n') |
| 226 | 225 |
| 227 # Create bin\python.bat on Windows to unify path where Python is found. | 226 # Create bin\python.bat on Windows to unify path where Python is found. |
| 228 if sys.platform.startswith('win'): | 227 if sys.platform.startswith('win'): |
| 229 bin_path = os.path.join(env, 'bin') | 228 bin_path = os.path.join(env, 'bin') |
| 230 if not os.path.isdir(bin_path): | 229 if not os.path.isdir(bin_path): |
| 231 os.makedirs(bin_path) | 230 os.makedirs(bin_path) |
| 232 python_bat_path = os.path.join(bin_path, 'python.bat') | 231 python_bat_path = os.path.join(bin_path, 'python.bat') |
| 233 if not os.path.isfile(python_bat_path): | 232 if not os.path.isfile(python_bat_path): |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 250 opts = parser.parse_args(args) | 249 opts = parser.parse_args(args) |
| 251 | 250 |
| 252 deps = merge_deps(opts.deps_file) | 251 deps = merge_deps(opts.deps_file) |
| 253 activate_env(opts.env_path, deps, opts.quiet) | 252 activate_env(opts.env_path, deps, opts.quiet) |
| 254 | 253 |
| 255 | 254 |
| 256 if __name__ == '__main__': | 255 if __name__ == '__main__': |
| 257 logging.basicConfig() | 256 logging.basicConfig() |
| 258 LOGGER.setLevel(logging.DEBUG) | 257 LOGGER.setLevel(logging.DEBUG) |
| 259 sys.exit(main(sys.argv[1:])) | 258 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |