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..f36877074c1b08013d543a1654349ecad45b7561 |
--- /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 |
+ |
+def Main(): |
+ if len(sys.argv) <= 1: |
+ print >> sys.stderr, 'Usage: build.py <output dir>' |
+ 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. |
Nico
2011/12/12 18:20:12
Can you use a _files prefix to let gyp do this tra
DaleCurtis
2011/12/12 19:23:20
If so, I couldn't get it to work. The problem is w
|
+ 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 gets confused about whether it has already generated psutil. 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() |