automake-patches
[Top][All Lists]
Advanced

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

Python 3.0 support


From: Johan Dahlin
Subject: Python 3.0 support
Date: Sun, 27 Jul 2008 15:53:58 +0200
User-agent: Thunderbird 2.0.0.14 (X11/20080501)

Hi, here are 4 patches adding Python 3.0 support for Automake.

Python 3.0 changes has major backwards incompatible changes, we have to be rather careful to use a subset which works on both 2.x and 3.x.
The patches have been tested on Python 2.5 and 3.0. I am confident that
they will work on versions as early as 2.0. Support for versions
prior to that has been dropped (2.0 was released in 2000) and that is
mentioned in the NEWS file.

I'm in the process of assigning my copyright to GNU.

Johan
From 803c8bb3a08f6abbb2ff84fb7cc57c369baee460 Mon Sep 17 00:00:00 2001
From: Johan Dahlin <address@hidden>
Date: Sun, 27 Jul 2008 15:19:35 +0200
Subject: [PATCH] Update py-compile to support python 3.0. This also drops 
support for python < 2.0.

---
 lib/py-compile |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/py-compile b/lib/py-compile
index 865cda8..9611765 100755
--- a/lib/py-compile
+++ b/lib/py-compile
@@ -101,38 +101,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
-- 
1.5.5.1

From 7fbc7266ceef1b69a36ccac7f4d051be8809ac5d Mon Sep 17 00:00:00 2001
From: Johan Dahlin <address@hidden>
Date: Sun, 27 Jul 2008 15:34:03 +0200
Subject: [PATCH] Add Python 3.0 support for AM_PATH_PYTHON and 
AM_PYTHON_CHECK_VERSION. Drop support for versions prior to Python 2.0, which 
was released on October 16, 2000.

---
 m4/python.m4 |   25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/m4/python.m4 b/m4/python.m4
index 229fd55..50df238 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -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])])
-- 
1.5.5.1

From 332da09aef16784056ebf117b508de9628499076 Mon Sep 17 00:00:00 2001
From: Johan Dahlin <address@hidden>
Date: Sun, 27 Jul 2008 15:46:58 +0200
Subject: [PATCH] Update NEWS

---
 NEWS |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/NEWS b/NEWS
index 181ba05..8a4320c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,10 @@
 New in 1.10a:
 
+* Changes to py-compile and m4/python.m4:
+
+  - Python 3.0 support, also note that Python releases prior to 2.0
+    are no longer supported.
+
 * Version requirements:
 
   - Autoconf 2.62 or greater is required.
-- 
1.5.5.1

From 6eba8d0970e89ae7921f9b5becd11bba56bc2afa Mon Sep 17 00:00:00 2001
From: Johan Dahlin <address@hidden>
Date: Sun, 27 Jul 2008 15:49:38 +0200
Subject: [PATCH] Update Python versions metioned in the manual. Use 2.5 
consistently.

---
 doc/automake.texi |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/automake.texi b/doc/automake.texi
index 5cb5642..919b361 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -7313,11 +7313,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
@@ -7341,7 +7341,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
@@ -10896,7 +10896,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,
@@ -10910,7 +10910,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
-- 
1.5.5.1


reply via email to

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