[pypy-commit] pypy default: ensure we only use python in the makefiles if it is really python2.5-2.7

RonnyPfannschmidt noreply at buildbot.pypy.org
Mon Sep 17 23:32:31 CEST 2012


Author: Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
Branch: 
Changeset: r57372:172bef2e2636
Date: 2012-09-17 23:31 +0200
http://bitbucket.org/pypy/pypy/changeset/172bef2e2636/

Log:	ensure we only use python in the makefiles if it is really
	python2.5-2.7

diff --git a/pypy/translator/c/genc.py b/pypy/translator/c/genc.py
--- a/pypy/translator/c/genc.py
+++ b/pypy/translator/c/genc.py
@@ -26,6 +26,24 @@
             file.close()
     return mod
 
+_CPYTHON_RE = py.std.re.compile('^Python 2.[567]')
+
+def get_recent_cpython_executable():
+
+    if sys.platform == 'win32':
+        python = sys.executable.replace('\\', '/') + ' '
+    else:
+        python = sys.executable + ' '
+
+    # Is there a command 'python' that runs python 2.5-2.7?
+    # If there is, then we can use it instead of sys.executable
+    returncode, stdout, stderr = runsubprocess.run_subprocess(
+        "python", "-V")
+    if _CPYTHON_RE.match(stdout) or _CPYTHON_RE.match(stderr):
+        python = 'python '
+    return python
+
+
 class ProfOpt(object):
     #XXX assuming gcc style flags for now
     name = "profopt"
@@ -574,18 +592,7 @@
             else:
                 mk.definition('PYPY_MAIN_FUNCTION', "main")
 
-            if sys.platform == 'win32':
-                python = sys.executable.replace('\\', '/') + ' '
-            else:
-                python = sys.executable + ' '
-
-            # Is there a command 'python' that runs python 2.5-2.7?
-            # If there is, then we can use it instead of sys.executable
-            returncode, stdout, stderr = runsubprocess.run_subprocess(
-                "python", "-V")
-            if (stdout.startswith('Python 2.') or
-                stderr.startswith('Python 2.')):
-                python = 'python '
+            python = get_recent_cpython_executable()
 
             if self.translator.platform.name == 'msvc':
                 lblofiles = []


More information about the pypy-commit mailing list