From: Yaakov Selkowitz <yselkow...@users.sourceforge.net>

* m4/python.m4 (AM_PATH_PYTHON): Add python3.3 to _AM_PYTHON_INTERPRETER_LIST.
* lib/py-compile: Fix compiled filenames for PEP-3147, currently implemented
in CPython 3.2 and newer.  Do not create .pyo files for PyPy.

Signed-off-by: Yaakov Selkowitz <yselkow...@users.sourceforge.net>
---
 lib/py-compile |   18 ++++++++++++++----
 m4/python.m4   |    2 +-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/lib/py-compile b/lib/py-compile
index 6916903..14d0d12 100755
--- a/lib/py-compile
+++ b/lib/py-compile
@@ -116,7 +116,7 @@ else
 fi
 
 $PYTHON -c "
-import sys, os, py_compile
+import sys, os, py_compile, imp
 
 files = '''$files'''
 
@@ -129,12 +129,19 @@ for file in files.split():
            continue
     sys.stdout.write(file)
     sys.stdout.flush()
-    py_compile.compile(filepath, filepath + 'c', path)
+    if hasattr(imp, 'get_tag'):
+        py_compile.compile(filepath, imp.cache_from_source(filepath), path)
+    else:
+        py_compile.compile(filepath, filepath + 'c', path)
 sys.stdout.write('\n')" || exit $?
 
 # this will fail for python < 1.5, but that doesn't matter ...
 $PYTHON -O -c "
-import sys, os, py_compile
+import sys, os, py_compile, imp
+
+# pypy does not use .pyo optimization
+if hasattr(sys, 'pypy_translation_info'):
+    sys.exit(0)
 
 files = '''$files'''
 sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n')
@@ -146,7 +153,10 @@ for file in files.split():
            continue
     sys.stdout.write(file)
     sys.stdout.flush()
-    py_compile.compile(filepath, filepath + 'o', path)
+    if hasattr(imp, 'get_tag'):
+        py_compile.compile(filepath, imp.cache_from_source(filepath, False), 
path)
+    else:
+        py_compile.compile(filepath, filepath + 'o', path)
 sys.stdout.write('\n')" 2>/dev/null || :
 
 # Local Variables:
diff --git a/m4/python.m4 b/m4/python.m4
index a247818..50213a9 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -37,7 +37,7 @@ AC_DEFUN([AM_PATH_PYTHON],
   dnl Find a Python interpreter.  Python versions prior to 2.0 are not
   dnl supported. (2.0 was released on October 16, 2000).
   m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
-[python python2 python3 python3.2 python3.1 python3.0 python2.7 dnl
+[python python2 python3 python3.3 python3.2 python3.1 python3.0 python2.7 dnl
  python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0])
 
   AC_ARG_VAR([PYTHON], [the Python interpreter])
-- 
1.7.9


Reply via email to