Chromium Code Reviews| Index: third_party/psutil/build.py |
| diff --git a/third_party/psutil/build.py b/third_party/psutil/build.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..2d885a3bd324eaaa2c461276fa96a661c86a5772 |
| --- /dev/null |
| +++ b/third_party/psutil/build.py |
| @@ -0,0 +1,44 @@ |
| +#!/usr/bin/env python |
| +# Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Simple helper script for building psutil via GYP.""" |
| + |
| +import os |
| +import shutil |
| +import subprocess |
| +import sys |
| +import tempfile |
| + |
|
Nirnimesh
2011/12/12 21:07:18
nit: leave another blank line here
|
| +def Main(): |
| + if len(sys.argv) <= 1: |
| + print >> sys.stderr, 'Usage: build.py <output dir>' |
|
Nirnimesh
2011/12/12 21:07:18
nit: remove space after >>
|
| + sys.exit(1) |
| + |
| + # GYP may specify the output path as a relative path. Since we need cwd to be |
| + # the source directory, we must convert the output path to an absolute path. |
| + abs_out_path = os.path.abspath(sys.argv[1]) |
| + temp_path = tempfile.mkdtemp() |
| + try: |
| + ret_code = subprocess.call( |
| + [sys.executable, 'setup.py', 'build', '--build-lib', abs_out_path, |
| + '--build-temp', temp_path], |
| + cwd=os.path.dirname(os.path.abspath(__file__))) |
| + |
| + # Since setup just copies the Python files over, timestamps remain unchanged |
| + # and GYP becomes confused about whether it has generated psutil or not. So |
| + # touch# all the Python related outputs to put GYP's mind at ease. |
| + python_outputs_path = os.path.join(abs_out_path, 'psutil') |
| + for fn in os.listdir(python_outputs_path): |
| + fn = os.path.join(python_outputs_path, fn) |
| + with file(fn, 'a'): |
| + os.utime(fn, None) |
| + |
| + sys.exit(ret_code) |
| + finally: |
| + shutil.rmtree(temp_path) |
| + |
| + |
| +if __name__ == '__main__': |
| + Main() |