[pypy-svn] r80009 - pypy/branch/out-of-line-guards/pypy/config

fijal at codespeak.net fijal at codespeak.net
Sun Dec 12 20:48:50 CET 2010


Author: fijal
Date: Sun Dec 12 20:48:48 2010
New Revision: 80009

Added:
   pypy/branch/out-of-line-guards/pypy/config/support.py
Log:
Another missing file from mergex


Added: pypy/branch/out-of-line-guards/pypy/config/support.py
==============================================================================
--- (empty file)
+++ pypy/branch/out-of-line-guards/pypy/config/support.py	Sun Dec 12 20:48:48 2010
@@ -0,0 +1,21 @@
+
+""" Some support code
+"""
+
+import re, sys, os
+
+def detect_number_of_processors(filename_or_file='/proc/cpuinfo'):
+    if sys.platform != 'linux2':
+        return 1    # implement me
+    if os.environ.get('MAKEFLAGS'):
+        return 1    # don't override MAKEFLAGS.  This will call 'make' without any '-j' option
+    try:
+        if isinstance(filename_or_file, str):
+            f = open(filename_or_file, "r")
+        else:
+            f = filename_or_file
+        return max([int(re.split('processor.*(\d+)', line)[1])
+                    for line in f.readlines()
+                    if line.startswith('processor')]) + 1
+    except:
+        return 1 # we really don't want to explode here, at worst we have 1



More information about the Pypy-commit mailing list