automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Python 3.0 support


From: Ralf Wildenhues
Subject: Re: Python 3.0 support
Date: Sun, 26 Oct 2008 10:35:09 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hi Johan,

long time ago, you submitted patches for Python 3.0 support.
Copyright papers are in place now (they've been for a few weeks
but apparently I hadn't been notified, and I was intelligent
enough to overlook them in the list last time).

So I've applied your changes to the git master branch of Automake
now, and put you in THANKS.

Many thanks again!

Cheers,
Ralf

2008-10-26  Johan Dahlin  <address@hidden>

        Support for Python 3.0, drop support for pre-2.0.
        * lib/py-compile: Do not import string; use sys.stdout.write
        instead of print, files.split instead of string.split.
        * m4/python.m4 (AM_PATH_PYTHON): Also look for python3 and
        phython3.0; do not look for python1.5.  Use sys.stdout.write.
        (AM_PYTHON_CHECK_VERSION): Do not use string; adjust to xrange
        removal in Python 3.0, and changed semantics of map.
        * doc/automake.texi (Python, Hard-Coded Install Paths): Update
        Python versions mentioned in the manual, using 2.5 everywhere.
        * NEWS, THANKS: Update.

diff --git a/NEWS b/NEWS
index 1a14ec6..42107a2 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,9 @@ New in 1.10a:
 
   - Files with extension .sx are also treated as preprocessed assembler.
 
+  - Python 3.0 is supported now, Python releases prior to 2.0 are no
+    longer supported.
+
 * Miscellaneous changes:
 
   - Automake development is done in a git repository on Savannah now, see
diff --git a/doc/automake.texi b/doc/automake.texi
index c2e0be5..122b977 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -7380,11 +7380,11 @@ AM_PATH_PYTHON([2.2])
 
 @noindent
 This is fine when Python is an absolute requirement for the package.
-If Python >= 2.2 was only @emph{optional} to the package,
+If Python >= 2.5 was only @emph{optional} to the package,
 @code{AM_PATH_PYTHON} could be called as follows.
 
 @example
-AM_PATH_PYTHON([2.2],, [:])
+AM_PATH_PYTHON([2.5],, [:])
 @end example
 
 @code{AM_PATH_PYTHON} creates the following output variables based on
@@ -7408,7 +7408,7 @@ as follows.
 
 @item PYTHON_VERSION
 The Python version number, in the form @address@hidden
-(e.g., @samp{1.5}).  This is currently the value of
+(e.g., @samp{2.5}).  This is currently the value of
 @samp{sys.version[:3]}.
 
 @item PYTHON_PREFIX
@@ -10983,7 +10983,7 @@ where to install the library, it will answer something 
like this:
 @example
 % @kbd{python -c 'from distutils import sysconfig;
              print sysconfig.get_python_lib(1,0)'}
-/usr/lib/python2.3/site-packages
+/usr/lib/python2.5/site-packages
 @end example
 
 If you indeed use this absolute path to install your shared library,
@@ -10997,7 +10997,7 @@ installation prefix.
 @example
 % @kbd{python -c 'from distutils import sysconfig;
              print sysconfig.get_python_lib(1,0,"address@hidden@}")'}
address@hidden@}/lib/python2.3/site-packages
address@hidden@}/lib/python2.5/site-packages
 @end example
 
 You can also use this new path.  If you do
diff --git a/lib/py-compile b/lib/py-compile
index 865cda8..88776bc 100755
--- a/lib/py-compile
+++ b/lib/py-compile
@@ -1,9 +1,10 @@
 #!/bin/sh
 # py-compile - Compile a Python program
 
-scriptversion=2005-05-14.22
+scriptversion=2008-10-26.11
 
-# Copyright (C) 2000, 2001, 2003, 2004, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2008  Free Software
+# Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -101,38 +102,38 @@ else
 fi
 
 $PYTHON -c "
-import sys, os, string, py_compile
+import sys, os, py_compile
 
 files = '''$files'''
 
-print 'Byte-compiling python modules...'
-for file in string.split(files):
+sys.stdout.write('Byte-compiling python modules...\n')
+for file in files.split():
     $pathtrans
     $filetrans
     if not os.path.exists(filepath) or not (len(filepath) >= 3
                                             and filepath[-3:] == '.py'):
-       continue
-    print file,
+           continue
+    sys.stdout.write(file)
     sys.stdout.flush()
     py_compile.compile(filepath, filepath + 'c', path)
-print" || exit $?
+sys.stdout.write('\n')" || exit $?
 
 # this will fail for python < 1.5, but that doesn't matter ...
 $PYTHON -O -c "
-import sys, os, string, py_compile
+import sys, os, py_compile
 
 files = '''$files'''
-print 'Byte-compiling python modules (optimized versions) ...'
-for file in string.split(files):
+sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n')
+for file in files.split():
     $pathtrans
     $filetrans
     if not os.path.exists(filepath) or not (len(filepath) >= 3
                                             and filepath[-3:] == '.py'):
-       continue
-    print file,
+           continue
+    sys.stdout.write(file)
     sys.stdout.flush()
     py_compile.compile(filepath, filepath + 'o', path)
-print" 2>/dev/null || :
+sys.stdout.write('\n')" 2>/dev/null || :
 
 # Local Variables:
 # mode: shell-script
diff --git a/m4/python.m4 b/m4/python.m4
index 229fd55..3adf87b 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -3,7 +3,7 @@
 ## From Andrew Dalke
 ## Updated by James Henstridge
 ## ------------------------
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
@@ -34,13 +34,11 @@
 # numbers and dots only.
 AC_DEFUN([AM_PATH_PYTHON],
  [
-  dnl Find a Python interpreter.  Python versions prior to 1.5 are not
-  dnl supported because the default installation locations changed from
-  dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
-  dnl in 1.5.
+  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 python2.5 python2.4 python2.3 python2.2 dnl
-python2.1 python2.0 python1.6 python1.5])
+                    [python python2 python3 python3.0 python2.5 python2.4 
python2.3 python2.2 dnl
+python2.1 python2.0])
 
   m4_if([$1],[],[
     dnl No version check is needed.
@@ -87,7 +85,7 @@ python2.1 python2.0 python1.6 python1.5])
   dnl library.
 
   AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
-    [am_cv_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`])
+    [am_cv_python_version=`$PYTHON -c "import sys; 
sys.stdout.write(sys.version[[:3]])"`])
   AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
 
   dnl Use the values of $prefix and $exec_prefix for the corresponding
@@ -102,7 +100,7 @@ python2.1 python2.0 python1.6 python1.5])
   dnl to know which OS platform Python thinks this is.
 
   AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
-    [am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`])
+    [am_cv_python_platform=`$PYTHON -c "import sys; 
sys.stdout.write(sys.platform)"`])
   AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
 
 
@@ -155,14 +153,15 @@ python2.1 python2.0 python1.6 python1.5])
 # Run ACTION-IF-FALSE otherwise.
 # This test uses sys.hexversion instead of the string equivalent (first
 # word of sys.version), in order to cope with versions such as 2.2c1.
-# hexversion has been introduced in Python 1.5.2; it's probably not
-# worth to support older versions (1.5.1 was released on October 31, 1998).
+# This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
 AC_DEFUN([AM_PYTHON_CHECK_VERSION],
- [prog="import sys, string
+ [prog="import sys
 # split strings by '.' and convert to numeric.  Append some zeros
 # because we need at least 4 digits for the hex conversion.
-minver = map(int, string.split('$2', '.')) + [[0, 0, 0]]
+# map returns an iterator in Python 3.0 and a list in 2.x
+minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
 minverhex = 0
-for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[[i]]
+# xrange is not present in Python 3.0 and range returns an iterator
+for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
 sys.exit(sys.hexversion < minverhex)"
   AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])





reply via email to

[Prev in Thread] Current Thread [Next in Thread]