From: Yaakov Selkowitz Date: Mon, 5 Nov 2012 17:45:15 +0000 (-0600) Subject: python: improve support for modern python (CPython 3.2 and PyPy) X-Git-Tag: v1.12.6~27^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0e99eda367180a73403e3d016e2255bc278e42e;p=thirdparty%2Fautomake.git python: improve support for modern python (CPython 3.2 and PyPy) This fixes automake bug#8847. * 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. Copyright-paperwork-exempt: yes Signed-off-by: Yaakov Selkowitz Signed-off-by: Stefano Lattarini --- diff --git a/lib/py-compile b/lib/py-compile index 691690374..14d0d1231 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 a2478181f..50213a9c9 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])