OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """Simple helper script for building psutil via GYP.""" | |
7 | |
8 import os | |
9 import shutil | |
10 import subprocess | |
11 import sys | |
12 import tempfile | |
13 | |
Nirnimesh
2011/12/12 21:07:18
nit: leave another blank line here
| |
14 def Main(): | |
15 if len(sys.argv) <= 1: | |
16 print >> sys.stderr, 'Usage: build.py <output dir>' | |
Nirnimesh
2011/12/12 21:07:18
nit: remove space after >>
| |
17 sys.exit(1) | |
18 | |
19 # GYP may specify the output path as a relative path. Since we need cwd to be | |
20 # the source directory, we must convert the output path to an absolute path. | |
21 abs_out_path = os.path.abspath(sys.argv[1]) | |
22 temp_path = tempfile.mkdtemp() | |
23 try: | |
24 ret_code = subprocess.call( | |
25 [sys.executable, 'setup.py', 'build', '--build-lib', abs_out_path, | |
26 '--build-temp', temp_path], | |
27 cwd=os.path.dirname(os.path.abspath(__file__))) | |
28 | |
29 # Since setup just copies the Python files over, timestamps remain unchanged | |
30 # and GYP becomes confused about whether it has generated psutil or not. So | |
31 # touch# all the Python related outputs to put GYP's mind at ease. | |
32 python_outputs_path = os.path.join(abs_out_path, 'psutil') | |
33 for fn in os.listdir(python_outputs_path): | |
34 fn = os.path.join(python_outputs_path, fn) | |
35 with file(fn, 'a'): | |
36 os.utime(fn, None) | |
37 | |
38 sys.exit(ret_code) | |
39 finally: | |
40 shutil.rmtree(temp_path) | |
41 | |
42 | |
43 if __name__ == '__main__': | |
44 Main() | |
OLD | NEW |