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 logging | 8 import logging |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 if cur_deps is None: | 139 if cur_deps is None: |
140 print ' Building new environment' | 140 print ' Building new environment' |
141 # Add in bundled virtualenv lib | 141 # Add in bundled virtualenv lib |
142 sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'virtualenv')) | 142 sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'virtualenv')) |
143 import virtualenv # pylint: disable=F0401 | 143 import virtualenv # pylint: disable=F0401 |
144 virtualenv.create_environment( | 144 virtualenv.create_environment( |
145 env, search_dirs=virtualenv.file_search_dirs()) | 145 env, search_dirs=virtualenv.file_search_dirs()) |
146 | 146 |
147 print ' Activating environment' | 147 print ' Activating environment' |
148 activate_this = os.path.join(env, 'bin', 'activate_this.py') | 148 bin_dir = 'Scripts' if virtualenv.is_win else 'bin' |
| 149 activate_this = os.path.join(env, bin_dir, 'activate_this.py') |
149 execfile(activate_this, dict(__file__=activate_this)) | 150 execfile(activate_this, dict(__file__=activate_this)) |
150 | 151 |
151 if cur_deps is None: | 152 if cur_deps is None: |
152 print ' Installing deps' | 153 print ' Installing deps' |
153 print_deps(deps, indent=2, with_implicit=False) | 154 print_deps(deps, indent=2, with_implicit=False) |
154 install(deps) | 155 install(deps) |
155 with open(manifest_path, 'wb') as f: | 156 with open(manifest_path, 'wb') as f: |
156 f.write(repr(deps) + '\n') | 157 f.write(repr(deps) + '\n') |
157 | 158 |
158 print 'Done creating environment' | 159 print 'Done creating environment' |
159 | 160 |
160 | 161 |
161 def main(args): | 162 def main(args): |
162 parser = argparse.ArgumentParser() | 163 parser = argparse.ArgumentParser() |
163 parser.add_argument('--deps_file', action='append', | 164 parser.add_argument('--deps_file', action='append', |
164 help='Path to deps.pyl file (may be used multiple times)') | 165 help='Path to deps.pyl file (may be used multiple times)') |
165 parser.add_argument('env_path', | 166 parser.add_argument('env_path', |
166 help='Path to place environment (default: %(default)s)', | 167 help='Path to place environment (default: %(default)s)', |
167 default='ENV') | 168 default='ENV') |
168 opts = parser.parse_args(args) | 169 opts = parser.parse_args(args) |
169 | 170 |
170 deps = merge_deps(opts.deps_file) | 171 deps = merge_deps(opts.deps_file) |
171 activate_env(opts.env_path, deps) | 172 activate_env(opts.env_path, deps) |
172 | 173 |
173 | 174 |
174 if __name__ == '__main__': | 175 if __name__ == '__main__': |
175 logging.basicConfig() | 176 logging.basicConfig() |
176 LOGGER.setLevel(logging.DEBUG) | 177 LOGGER.setLevel(logging.DEBUG) |
177 sys.exit(main(sys.argv[1:])) | 178 sys.exit(main(sys.argv[1:])) |
OLD | NEW |