automake-commit
[Top][All Lists]
Advanced

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

[Automake-commit] [SCM] GNU Automake branch, maint, updated. v1.12.5-12-


From: Stefano Lattarini
Subject: [Automake-commit] [SCM] GNU Automake branch, maint, updated. v1.12.5-12-g8d1a542
Date: Wed, 21 Nov 2012 13:41:27 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Automake".

http://git.sv.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=8d1a542296ca5d9137644387ebe1611239e41018

The branch, maint has been updated
       via  8d1a542296ca5d9137644387ebe1611239e41018 (commit)
       via  1d73b276595cd1c6d57998e4148601dbf2844425 (commit)
       via  e1acf4a06f5a8d9e861455ac29abb4944a446494 (commit)
       via  3fea76478eb1364093804365904fdb3c1e5c93d2 (commit)
       via  cae0d860a5bce1593d1be0ce22f3dae81c825230 (commit)
       via  c3dc900373daa90464d3f16598f941c5a564c3b5 (commit)
       via  2ccd405661bf7f49d14c5be54d4adacb046d521c (commit)
       via  b2d3483c33079b333d96d1c8ee893c17974ae666 (commit)
       via  e0e99eda367180a73403e3d016e2255bc278e42e (commit)
      from  2f584fa4f117c5d745b0b7b4f57686f2f83424b0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8d1a542296ca5d9137644387ebe1611239e41018
Merge: 2f584fa 1d73b27
Author: Stefano Lattarini <address@hidden>
Date:   Wed Nov 21 10:28:41 2012 +0100

    Merge branch 'python-pep-3147' into maint
    
    * python-pep-3147:
      tests: fix a spurious failure when $PYTHON is in the environment
      python tests: support PEP-3147 installation layout
      python: uninstall cater to PEP-3147
      tests: improve a comment
      tests: honour $PYTHON override
      tests: typofix in message
      news: document fix for bug#8847 (PEP-3147, __pycache__)
      python: improve support for modern python (CPython 3.2 and PyPy)

commit 1d73b276595cd1c6d57998e4148601dbf2844425
Author: Stefano Lattarini <address@hidden>
Date:   Mon Nov 19 22:56:22 2012 +0100

    tests: fix a spurious failure when $PYTHON is in the environment
    
    * t/python11.sh: This test doesn't interact well with user-overrides of
    $PYTHON; and, given its particular nature, neither should it be expected
    to honour that override.  Just unset that $PYTHON variable and live
    happy.
    
    Signed-off-by: Stefano Lattarini <address@hidden>

commit e1acf4a06f5a8d9e861455ac29abb4944a446494
Author: Stefano Lattarini <address@hidden>
Date:   Mon Nov 19 22:19:21 2012 +0100

    python tests: support PEP-3147 installation layout
    
    This fixes several spurious testsuite failures with python >= 3.2,
    introduced by recent commit v1.12.4-43-ge0e99ed, "python: improve
    support for modern python (CPython 3.2 and PyPy)".
    
    * t/ax/am-test-lib.sh (python_has_pep3147, pyc_location, py_installed):
    New functions.
    ($am_pep3147_tag): New variable.
    * t/py-compile-basic2.sh: Deleted, too difficult to adapt for the
    gain it would offer; move the still relevant parts ...
    * t/py-compile-basic.sh: ... here.  Adapt and adjust the rest of
    the test as well.
    * t/nobase-python.sh: Adapt and adjust.
    * t/py-compile-basedir.sh: Likewise.
    * t/py-compile-destdir.sh: Likewise.
    * t/py-compile-option-terminate.sh: Likewise.
    * t/python-pr10995.sh: Likewise.
    * t/python-virtualenv.sh: Likewise.
    * t/python10.sh: Likewise.
    * t/python12.sh: Likewise.
    * t/python3.sh: Likewise.
    * t/list-of-tests.mk: Adjust list of tests.
    
    Signed-off-by: Stefano Lattarini <address@hidden>

commit 3fea76478eb1364093804365904fdb3c1e5c93d2
Author: Stefano Lattarini <address@hidden>
Date:   Mon Nov 19 20:16:47 2012 +0100

    python: uninstall cater to PEP-3147
    
    After recent commit commit v1.12.4-43-ge0e99ed, "python: improve
    support for modern python (CPython 3.2 and PyPy)", the python install
    rules have been made smart enough to install "*.pyc" byte-compiled
    files according to PEP-3147 with modern (post-3.2) pythons.  However,
    the uninstall rules hadn't been updated accordingly, causing leftover
    files to remain around after "make uninstall", as well as failures in
    "make distcheck".
    
    * lib/am/python.am (am__pep3147_tweak): New internal macro, used
    in ...
    (uninstall-%DIR%PYTHON): ... the recipe of this target, which has
    been adjusted to cater to PEP-3147
    
    Signed-off-by: Stefano Lattarini <address@hidden>

commit cae0d860a5bce1593d1be0ce22f3dae81c825230
Author: Stefano Lattarini <address@hidden>
Date:   Sun Nov 11 12:39:40 2012 +0100

    tests: improve a comment
    
    * t/ax/am-test-lib.sh (require_tool): Here, about python support
    for '--version' option.
    
    Signed-off-by: Stefano Lattarini <address@hidden>

commit c3dc900373daa90464d3f16598f941c5a564c3b5
Author: Stefano Lattarini <address@hidden>
Date:   Sun Nov 11 12:03:46 2012 +0100

    tests: honour $PYTHON override
    
    * t/ax/am-test-lib.sh (require_tool): Here.
    * t/python-too-old.sh: And here.
    * t/python-vars.sh: And here.
    * t/python-virtualenv.sh: And here.  Also add some sanity
    checks while at it.
    
    Signed-off-by: Stefano Lattarini <address@hidden>

commit 2ccd405661bf7f49d14c5be54d4adacb046d521c
Author: Stefano Lattarini <address@hidden>
Date:   Sun Nov 11 11:55:43 2012 +0100

    tests: typofix in message
    
    * t/python-virtualenv.sh: Here.
    
    Signed-off-by: Stefano Lattarini <address@hidden>

commit b2d3483c33079b333d96d1c8ee893c17974ae666
Author: Stefano Lattarini <address@hidden>
Date:   Sun Nov 11 11:43:06 2012 +0100

    news: document fix for bug#8847 (PEP-3147, __pycache__)
    
    * NEWS (Bugs fixed in 1.12.5): Here.
    
    Signed-off-by: Stefano Lattarini <address@hidden>

commit e0e99eda367180a73403e3d016e2255bc278e42e
Author: Yaakov Selkowitz <address@hidden>
Date:   Mon Nov 5 11:45:15 2012 -0600

    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 <address@hidden>
    Signed-off-by: Stefano Lattarini <address@hidden>

-----------------------------------------------------------------------

Summary of changes:
 NEWS                             |    3 +
 lib/am/python.am                 |   30 ++++++++++--
 lib/py-compile                   |   18 ++++++--
 m4/python.m4                     |    2 +-
 t/ax/am-test-lib.sh              |   66 +++++++++++++++++++++++++-
 t/list-of-tests.mk               |    1 -
 t/nobase-python.sh               |   50 +++++++++++---------
 t/py-compile-basedir.sh          |   18 ++++---
 t/py-compile-basic.sh            |   19 +++++--
 t/py-compile-basic2.sh           |   70 ----------------------------
 t/py-compile-destdir.sh          |   22 +++++----
 t/py-compile-option-terminate.sh |   20 ++++----
 t/python-pr10995.sh              |    8 ++--
 t/python-too-old.sh              |    3 +-
 t/python-vars.sh                 |    2 -
 t/python-virtualenv.sh           |   95 ++++++++++++++++++++++----------------
 t/python10.sh                    |   36 +++++++-------
 t/python11.sh                    |    3 +
 t/python12.sh                    |   14 +++---
 t/python3.sh                     |    6 +-
 20 files changed, 272 insertions(+), 214 deletions(-)
 delete mode 100755 t/py-compile-basic2.sh

diff --git a/NEWS b/NEWS
index e1fcd27..c593896 100644
--- a/NEWS
+++ b/NEWS
@@ -114,6 +114,9 @@ Bugs fixed in 1.12.5:
     finding classic 'libname.a' style libraries when 'name.lib' and
     'name.dll.lib' aren't available.
 
+  - Python byte-compilation supports the new layout mandated by PEP-3147,
+    with its __pycache__ directory (automake bug#8847).
+
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 New in 1.12.4:
diff --git a/lib/am/python.am b/lib/am/python.am
index cab6129..2f12af4 100644
--- a/lib/am/python.am
+++ b/lib/am/python.am
@@ -94,19 +94,37 @@ endif %?INSTALL%
 ## -------------- ##
 
 if %?INSTALL%
+
+?FIRST?am__pep3147_tweak = \
+?FIRST?  sed -e 's|\.py$$||' -e 's|[^/]*$$|__pycache__/&.*.py|'
+
 .PHONY uninstall-am: uninstall-%DIR%PYTHON
 uninstall-%DIR%PYTHON:
        @$(NORMAL_UNINSTALL)
        @list='$(%DIR%_PYTHON)'; test -n "$(%NDIR%dir)" || list=; \
-?BASE? files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
-?!BASE?        $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
-       test -n "$$files" || exit 0; \
+?BASE? py_files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+?!BASE?        $(am__nobase_strip_setup); py_files=`$(am__nobase_strip)`; \
+       test -n "$$py_files" || exit 0; \
        dir='$(DESTDIR)$(%NDIR%dir)'; \
 ## Also remove the .pyc and .pyo byte compiled versions.
-       filesc=`echo "$$files" | sed 's|$$|c|'`; \
-       fileso=`echo "$$files" | sed 's|$$|o|'`; \
+## This is somewhat tricky, because for newer pythons we have to take
+## PEP-3147 into account.
+       pyc_files=`echo "$$py_files" | sed 's|$$|c|'`; \
+       pyo_files=`echo "$$py_files" | sed 's|$$|o|'`; \
+       py_files_pep3147=`echo "$$py_files" | $(am__pep3147_tweak)`; \
+       echo "$$py_files_pep3147";\
+       pyc_files_pep3147=`echo "$$py_files_pep3147" | sed 's|$$|c|'`; \
+       pyo_files_pep3147=`echo "$$py_files_pep3147" | sed 's|$$|o|'`; \
        st=0; \
-       for files in "$$files" "$$filesc" "$$fileso"; do \
+       for files in \
+         "$$py_files" \
+         "$$pyc_files" \
+         "$$pyo_files" \
+## Installation of '.py' files is not influenced by PEP-3147, so it
+## is correct *not* to have $pyfiles_pep3147 here.
+         "$$pyc_files_pep3147" \
+         "$$pyo_files_pep3147" \
+       ; do \
          $(am__uninstall_files_from_dir) || st=$$?; \
        done; \
        exit $$st
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])
diff --git a/t/ax/am-test-lib.sh b/t/ax/am-test-lib.sh
index e69a904..5725f28 100644
--- a/t/ax/am-test-lib.sh
+++ b/t/ax/am-test-lib.sh
@@ -443,6 +443,65 @@ fetch_tap_driver ()
 # use the perl implementation by default for the moment.
 am_tap_implementation=${am_tap_implementation-shell}
 
+# $PYTHON and support for PEP-3147.  Needed to check our python-related
+# install rules.
+python_has_pep3147 ()
+{
+  if test -z "$am_pep3147_tag"; then
+    am_pep3147_tag=$($PYTHON -c 'import imp; print(imp.get_tag())') \
+      || am_pep3147_tag=none
+  fi
+  test $am_pep3147_tag != none
+}
+am_pep3147_tag=
+
+# pyc_location [-p] [FILE]
+# ------------------------
+# Determine what the actual location of the given '.pyc' or '.pyo'
+# byte-compiled file should be, taking into account PEP-3147.  Save
+# the location in the '$am_pyc_file' variable.  If the '-p' option
+# is given, print the location on the standard output as well.
+pyc_location ()
+{
+  case $#,$1 in
+    2,-p) am_pyc_print=yes; shift;;
+     1,*) am_pyc_print=no;;
+       *) fatal_ "pyc_location: invalid usage";;
+  esac
+  if python_has_pep3147; then
+    case $1 in
+      */*) am_pyc_dir=${1%/*} am_pyc_base=${1##*/};;
+        *) am_pyc_dir=. am_pyc_base=$1;;
+    esac
+    am_pyc_ext=${am_pyc_base##*.}
+    am_pyc_base=${am_pyc_base%.py?}
+    
am_pyc_file=$am_pyc_dir/__pycache__/$am_pyc_base.$am_pep3147_tag.$am_pyc_ext
+  else
+    am_pyc_file=$1
+  fi
+  test $am_pyc_print = no || printf '%s\n' "$am_pyc_file"
+}
+
+# py_installed [--not] FILE
+# --------------------------
+# Check that the given python FILE has been installed (resp. *not*
+# installed, if the '--not' option is specified).  If FILE is a
+# byte-compiled '.pyc' file, the new installation layout specified
+# by PEP-3147 will be taken into account.
+py_installed ()
+{
+  case $#,$1 in
+        1,*) am_test_py_file='test -f';;
+    2,--not) am_test_py_file='test ! -e'; shift;;
+          *) fatal_ "pyc_installed: invalid usage";;
+  esac
+  case $1 in
+    *.py[co]) pyc_location "$1"; am_target_py_file=$am_pyc_file;;
+           *) am_target_py_file=$1;;
+  esac
+  $am_test_py_file "$am_target_py_file"
+}
+
 # Usage: require_compiler_ {cc|c++|fortran|fortran77}
 require_compiler_ ()
 {
@@ -661,9 +720,10 @@ require_tool ()
       ! cross_compiling || skip_all_ "doesn't work in cross-compile mode"
       ;;
     python)
-      # Python doesn't support --version, it has -V
-      echo "$me: running python -V"
-      python -V || skip_all_ "python interpreter not available"
+      PYTHON=${PYTHON-python}
+      # Older python versions don't support --version, they have -V.
+      echo "$me: running $PYTHON -V"
+      $PYTHON -V || skip_all_ "python interpreter not available"
       ;;
     ro-dir)
       # Skip this test case if read-only directories aren't supported
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 4d84940..8d551d1 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -882,7 +882,6 @@ t/print-libdir.sh \
 t/proginst.sh \
 t/programs-primary-rewritten.sh \
 t/py-compile-basic.sh \
-t/py-compile-basic2.sh \
 t/py-compile-basedir.sh \
 t/py-compile-destdir.sh \
 t/py-compile-env.sh \
diff --git a/t/nobase-python.sh b/t/nobase-python.sh
index dba17f7..6480f26 100755
--- a/t/nobase-python.sh
+++ b/t/nobase-python.sh
@@ -28,21 +28,31 @@ cat > Makefile.am <<'END'
 mydir=$(prefix)/my
 my_PYTHON = one.py sub/base.py
 nobase_my_PYTHON = two.py sub/nobase.py
-
-test-install-data: install-data
-       find inst -print; : For debugging.
-       test   -f inst/my/one.py
-       test   -f inst/my/one.pyc
-       test   -f inst/my/two.py
-       test   -f inst/my/two.pyc
-       test   -f inst/my/base.py
-       test   -f inst/my/base.pyc
-       test   -f inst/my/sub/nobase.py
-       test   -f inst/my/sub/nobase.pyc
-       test ! -f inst/my/nobase.py
-       test ! -f inst/my/nobase.pyc
 END
 
+test_install()
+{
+  $MAKE install-data
+  find inst -print # For debugging.
+  py_installed inst/my/one.py
+  py_installed inst/my/one.pyc
+  py_installed inst/my/two.py
+  py_installed inst/my/two.pyc
+  py_installed inst/my/base.py
+  py_installed inst/my/base.pyc
+  py_installed inst/my/sub/nobase.py
+  py_installed inst/my/sub/nobase.pyc
+  py_installed --not inst/my/nobase.py
+  py_installed --not inst/my/nobase.pyc
+}
+
+test_uninstall()
+{
+  $MAKE uninstall
+  test -d inst/my
+  ! find inst/my -type f -print | grep .
+}
+
 mkdir sub
 
 for file in one.py sub/base.py two.py sub/nobase.py; do
@@ -56,23 +66,19 @@ $AUTOMAKE --add-missing
 ./configure --prefix "$(pwd)/inst" --program-prefix=p
 
 $MAKE
-$MAKE test-install-data
-$MAKE uninstall
-
-find inst/my -type f -print | grep . && exit 1
+test_install
+test_uninstall
 
 $MAKE install-strip
+test_uninstall
 
 # Likewise, in a VPATH build.
 
-$MAKE uninstall
 $MAKE distclean
 mkdir build
 cd build
 ../configure --prefix "$(pwd)/inst" --program-prefix=p
-$MAKE
-$MAKE test-install-data
-$MAKE uninstall
-find inst/my -type f -print | grep . && exit 1
+test_install
+test_uninstall
 
 :
diff --git a/t/py-compile-basedir.sh b/t/py-compile-basedir.sh
index f2cef30..75b45f7 100755
--- a/t/py-compile-basedir.sh
+++ b/t/py-compile-basedir.sh
@@ -38,13 +38,17 @@ for d in foo foo/bar "$(pwd)/foo" . .. ../foo ''; do
   : > "$d2/$f.py"
   : > "$d2/sub/$f.py"
   ./py-compile --basedir "$d" "$f.py" "sub/$f.py"
-  ls -l "$d2" "$d2/sub" # For debugging.
-  test -f "$d2/$f.pyc"
-  test -f "$d2/$f.pyo"
-  test -f "$d2/sub/$f.pyc"
-  test -f "$d2/sub/$f.pyo"
-  rm -f "$d2/$f.pyc" "$d2/$f.pyo" "$d2/sub/$f.pyc" "$d2/sub/$f.pyo"
-  find . | grep '\.py[co]$' && exit 1
+  find "$d2" # For debugging.
+  py_installed "$d2/$f.pyc"
+  py_installed "$d2/$f.pyo"
+  py_installed "$d2/sub/$f.pyc"
+  py_installed "$d2/sub/$f.pyo"
+  files=$(find "$d2" | grep '\.py[co]$')
+  test $(echo "$files" | wc -l) -eq 4
+  case $d2 in
+    .|..) rm -f $files;;
+       *) rm -rf "$d2";;
+  esac
 done
 
 :
diff --git a/t/py-compile-basic.sh b/t/py-compile-basic.sh
index 73597c3..cc5fec3 100755
--- a/t/py-compile-basic.sh
+++ b/t/py-compile-basic.sh
@@ -46,7 +46,8 @@ class Foo:
 bar = baz = (1, (2,), [3, 4]); zardoz = 0;
 END
 
-cat > bar.py <<'END'
+mkdir sub
+cat > sub/bar.py <<'END'
 # Import of non-existent modules, or assertion of false conditions,
 # shouldn't cause problems, as it should be enough for the code to
 # be syntactically correct.
@@ -54,10 +55,16 @@ import Automake.No.Such.Module
 assert False
 END
 
-./py-compile foo.py bar.py
-test -f foo.pyc
-test -f foo.pyo
-test -f bar.pyc
-test -f bar.pyo
+# An empty file in a more deeply-nested directory should be ok as well.
+mkdir -p 1/_/2/_/3/_
+: > 1/_/2/_/3/_/0.py
+
+./py-compile foo.py sub/bar.py 1/_/2/_/3/_/0.py
+py_installed foo.pyc
+py_installed foo.pyo
+py_installed sub/bar.pyc
+py_installed sub/bar.pyo
+py_installed 1/_/2/_/3/_/0.pyc
+py_installed 1/_/2/_/3/_/0.pyo
 
 :
diff --git a/t/py-compile-basic2.sh b/t/py-compile-basic2.sh
deleted file mode 100755
index 19fdf72..0000000
--- a/t/py-compile-basic2.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2011-2012 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
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# Test more basic functionalities of the 'py-compile' script, with
-# dummy python sources, but more complex directory layouts.  See also
-# related test 'py-compile-basic.sh'.
-
-required=python
-. ./defs || exit 1
-
-ocwd=$(pwd) || fatal_ "getting current working directory"
-
-pyfiles="
-  foo.py
-  ./foo1.py
-  ../foo2.py
-  ../dir/foo3.py
-  $ocwd/foo4.py
-  sub/bar.py
-  sub/subsub/barbar.py
-  __init__.py
-  sub/__init__.py
-  1.py
-  .././_.py
-"
-
-lst='
-  dir/foo
-  dir/foo1
-  foo2
-  dir/foo3
-  foo4
-  dir/sub/bar
-  dir/sub/subsub/barbar
-  dir/__init__
-  dir/sub/__init__
-  dir/1
-  _
-'
-
-mkdir dir
-cd dir
-cp "$am_scriptdir/py-compile" . \
-  || fatal_ "failed to fetch auxiliary script py-compile"
-mkdir sub sub/subsub
-touch $pyfiles
-./py-compile $pyfiles
-cd "$ocwd"
-
-for x in $lst; do echo $x.pyc; echo $x.pyo; done | sort > exp
-find . -name '*.py[co]' | sed 's|^\./||' | sort > got
-
-cat exp
-cat got
-diff exp got
-
-:
diff --git a/t/py-compile-destdir.sh b/t/py-compile-destdir.sh
index 4d303d5..ba666f6 100755
--- a/t/py-compile-destdir.sh
+++ b/t/py-compile-destdir.sh
@@ -1,4 +1,4 @@
-#! /bin/sh
+    #! /bin/sh
 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -31,13 +31,17 @@ echo 'def foo (): return "foo"' > $destdir/foo.py
 echo 'def bar (): return "bar"' > $destdir/sub/bar.py
 
 ./py-compile --destdir $destdir foo.py sub/bar.py
-ls -l $destdir $destdir/sub # For debugging.
-ls . sub | grep '\.py[co]$' && exit 1
-test -f $destdir/foo.pyc
-test -f $destdir/foo.pyo
-test -f $destdir/sub/bar.pyc
-test -f $destdir/sub/bar.pyo
-strings $destdir/*.py[co] $destdir/sub/*.py[co] || : # For debugging.
-$FGREP $destdir $destdir/*.py[co] $destdir/sub/*.py[co] && exit 1
+
+find $destdir # For debugging.
+st=0
+for x in c o; do
+  for b in foo sub/bar; do
+    f=$(pyc_location -p "$destdir/$b.py$x")
+    test -f "$f"
+    strings "$f" || : # For debugging.
+    $FGREP $destdir $f && { echo BAD: $f; st=1; }
+  done
+done
+exit $st
 
 :
diff --git a/t/py-compile-option-terminate.sh b/t/py-compile-option-terminate.sh
index 5c2b56f..0ad1fd8 100755
--- a/t/py-compile-option-terminate.sh
+++ b/t/py-compile-option-terminate.sh
@@ -26,18 +26,18 @@ cp "$am_scriptdir/py-compile" . \
 : > ./-o.py
 : > ./--foo.py
 ./py-compile -- -o.py --foo.py
-test -f ./-o.pyc
-test -f ./-o.pyo
-test -f ./--foo.pyc
-test -f ./--foo.pyo
+py_installed ./-o.pyc
+py_installed ./-o.pyo
+py_installed ./--foo.pyc
+py_installed ./--foo.pyo
 rm -f ./-*.py[co]
 : > x.py
 ./py-compile x.py -o.py --foo.py
-test -f ./x.pyc
-test -f ./x.pyo
-test -f ./-o.pyc
-test -f ./-o.pyo
-test -f ./--foo.pyc
-test -f ./--foo.pyo
+py_installed ./x.pyc
+py_installed ./x.pyo
+py_installed ./-o.pyc
+py_installed ./-o.pyo
+py_installed ./--foo.pyc
+py_installed ./--foo.pyo
 
 :
diff --git a/t/python-pr10995.sh b/t/python-pr10995.sh
index c530a13..63e97c5 100755
--- a/t/python-pr10995.sh
+++ b/t/python-pr10995.sh
@@ -46,10 +46,10 @@ test -f py-compile
 
 ./configure --prefix="$(pwd)/inst"
 $MAKE install
-test -f inst/py/yes.py
-test -f inst/py/yes.pyc
-test ! -e inst/py/no.py
-test ! -e inst/py/no.pyc
+test -f            inst/py/yes.py
+test ! -e          inst/py/no.py
+py_installed       inst/py/yes.pyc
+py_installed --not inst/py/no.pyc
 
 $MAKE disttest
 
diff --git a/t/python-too-old.sh b/t/python-too-old.sh
index e4185fc..b479c9e 100755
--- a/t/python-too-old.sh
+++ b/t/python-too-old.sh
@@ -34,6 +34,7 @@ py_too_old ()
   grep '[Pp]ython interpreter is too old' stderr
 }
 
+saved_PYTHON=$PYTHON; export saved_PYTHON
 PYTHON=; unset PYTHON
 
 cat > configure.ac <<END
@@ -50,7 +51,7 @@ py_too_old python
 mkdir bin
 cat > bin/my-python << 'END'
 #! /bin/sh
-exec python ${1+"$@"}
+exec $saved_PYTHON ${1+"$@"}
 END
 chmod a+x bin/my-python
 PATH=$(pwd)/bin$PATH_SEPARATOR$PATH
diff --git a/t/python-vars.sh b/t/python-vars.sh
index 5bac280..0c2c08b 100755
--- a/t/python-vars.sh
+++ b/t/python-vars.sh
@@ -23,8 +23,6 @@ required=python
 # In case the user's config.site defines pythondir or pyexecdir.
 CONFIG_SITE=/dev/null; export CONFIG_SITE
 
-PYTHON=python
-
 # Update the definition below if the documentation changes.
 # Note that the value of the 'pythondir' and 'pyexecdir' variables can
 # vary among different python installations, so we need more relaxed
diff --git a/t/python-virtualenv.sh b/t/python-virtualenv.sh
index 51ae78e..89a99aa 100755
--- a/t/python-virtualenv.sh
+++ b/t/python-virtualenv.sh
@@ -23,9 +23,11 @@ required='cc python virtualenv'
 # In case the user's config.site defines pythondir or pyexecdir.
 CONFIG_SITE=/dev/null; export CONFIG_SITE
 
+py_version_pre=$($PYTHON -V)
+
 # Skip the test if a proper virtualenv cannot be created.
-virtualenv --verbose virtenv && test -f virtenv/bin/activate \
-  || skip_ "coulnd't create python virtual environment"
+virtualenv -p"$PYTHON" --verbose virtenv && py_installed virtenv/bin/activate \
+  || skip_ "couldn't create python virtual environment"
 
 # Activate the virtualenv.
 . ./virtenv/bin/activate
@@ -34,16 +36,29 @@ if test -z "$VIRTUAL_ENV"; then
   framework_failure_ "can't activate python virtual environment"
 fi
 
+py_version_post=$(python -V)
+
+# Sanity check.
+test "$py_version_pre" = "$py_version_post"
+
 cwd=$(pwd) || fatal_ "getting current working directory"
 py_version=$(python -c 'import sys; print("%u.%u" % 
tuple(sys.version_info[:2]))')
 py_site=$VIRTUAL_ENV/lib/python$py_version/site-packages
 
+# We need to do do this early, just to set some cache variables properly,
+# since because we're going to unset $PYTHON next.
+if python_has_pep3147; then
+  : PEP 3147 will be used in installation of ".pyc" files
+fi
+# We don't want our original python to be picked up by configure
+# invocations.
+unset PYTHON
+
 # We need control over the package name.
 cat > configure.ac << END
 AC_INIT([am_virtenv], [1.0])
 AM_INIT_AUTOMAKE
 AC_CONFIG_FILES([Makefile])
-AC_SUBST([MY_VIRTENV], ['$cwd/virtenv'])
 AC_PROG_CC
 AM_PROG_AR
 AC_PROG_RANLIB
@@ -59,9 +74,7 @@ libquux_a_SOURCES = foo.c
 pkgpyexec_LIBRARIES = libzardoz.a
 libzardoz_a_SOURCES = foo.c
 
-py_site = $(MY_VIRTENV)/lib/python$(PYTHON_VERSION)/site-packages
-
-.PYTHON: debug test-run test-install test-uninstall
+.PYTHON: debug test-run
 debug:
        @echo PYTHON: $(PYTHON)
        @echo PYTHON_VERSION: $(PYTHON_VERSION)
@@ -85,24 +98,6 @@ test-run:
        ## available.
        python -c 'from am_foo import foo_func; assert (foo_func () == 12345)'
        python -c 'from am_virtenv import old_am; assert (old_am () == 
"AutoMake")'
-test-install:
-       test -f $(py_site)/am_foo.py
-       test -f $(py_site)/am_foo.pyc
-       test -f $(py_site)/am_foo.pyo
-       test -f $(py_site)/am_virtenv/__init__.py
-       test -f $(py_site)/am_virtenv/__init__.pyc
-       test -f $(py_site)/am_virtenv/__init__.pyo
-       test -f $(py_site)/libquux.a
-       test -f $(py_site)/am_virtenv/libzardoz.a
-test-uninstall:
-       test ! -f $(py_site)/am_foo.py
-       test ! -f $(py_site)/am_foo.pyc
-       test ! -f $(py_site)/am_foo.pyo
-       test ! -f $(py_site)/am_virtenv/__init__.py
-       test ! -f $(py_site)/am_virtenv/__init__.pyc
-       test ! -f $(py_site)/am_virtenv/__init__.pyo
-       test ! -f $(py_site)/libquux.a
-       test ! -f $(py_site)/am_virtenv/libzardoz.a
 all-local: debug
 END
 
@@ -123,6 +118,34 @@ int foo (void)
 }
 END
 
+check_install ()
+{
+  $MAKE install ${1+"$@"}
+
+  test -f      "$py_site"/am_foo.py
+  py_installed "$py_site"/am_foo.pyc
+  py_installed "$py_site"/am_foo.pyo
+  py_installed "$py_site"/am_virtenv/__init__.py
+  py_installed "$py_site"/am_virtenv/__init__.pyc
+  py_installed "$py_site"/am_virtenv/__init__.pyo
+  test -f      "$py_site"/libquux.a
+  test -f      "$py_site"/am_virtenv/libzardoz.a
+}
+
+check_uninstall ()
+{
+  $MAKE uninstall ${1+"$@"}
+
+  test ! -e          "$py_site"/am_foo.py
+  py_installed --not "$py_site"/am_foo.pyc
+  py_installed --not "$py_site"/am_foo.pyo
+  test ! -e          "$py_site"/am_virtenv/__init__.py
+  py_installed --not "$py_site"/am_virtenv/__init__.pyc
+  py_installed --not "$py_site"/am_virtenv/__init__.pyo
+  test ! -e          "$py_site"/libquux.a
+  test ! -e          "$py_site"/am_virtenv/libzardoz.a
+}
+
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
@@ -131,31 +154,25 @@ $AUTOMAKE --add-missing
 mkdir build
 cd build
 ../configure --prefix="$VIRTUAL_ENV"
-$MAKE install
-$MAKE test-install
+check_install
 $MAKE test-run
-$MAKE uninstall
-$MAKE test-uninstall
+check_uninstall
 cd ..
 
 # Try an in-tree build.
 ./configure --prefix="$VIRTUAL_ENV"
-$MAKE install
-$MAKE test-install
+check_install
 $MAKE test-run
-$MAKE uninstall
-$MAKE test-uninstall
+check_uninstall
 
 $MAKE distclean
 
 # Overriding pythondir and pyexecdir with cache variables should work.
 ./configure am_cv_python_pythondir="$py_site" \
             am_cv_python_pyexecdir="$py_site"
-$MAKE install
-$MAKE test-install
+check_install
 $MAKE test-run
-$MAKE uninstall
-$MAKE test-uninstall
+check_uninstall
 
 $MAKE distclean
 
@@ -163,12 +180,10 @@ $MAKE distclean
 ./configure --prefix="$cwd/bad-prefix"
 pythondir=$py_site pyexecdir=$py_site
 export pythondir pyexecdir
-$MAKE -e install
+check_install -e
 test ! -e bad-prefix
-$MAKE -e test-install
 $MAKE test-run
-$MAKE -e uninstall
-$MAKE -e test-uninstall
+check_uninstall -e
 unset pythondir pyexecdir
 
 # Also check that the distribution is self-contained, for completeness.
diff --git a/t/python10.sh b/t/python10.sh
index 5465810..8814902 100755
--- a/t/python10.sh
+++ b/t/python10.sh
@@ -58,29 +58,29 @@ cwd=$(pwd) || fatal_ "getting current working directory"
 
 ../configure --prefix="$cwd/$inst" one=0
 $MAKE install
-test -f "$inst/your/two.py"
-test -f "$inst/your/two.pyc"
-test -f "$inst/your/two.pyo"
-test ! -e "$inst/my/one.py"
-test ! -e "$inst/my/one.pyc"
-test ! -e "$inst/my/one.pyo"
+test -f            "$inst/your/two.py"
+py_installed       "$inst/your/two.pyc"
+py_installed       "$inst/your/two.pyo"
+py_installed --not "$inst/my/one.py"
+py_installed --not "$inst/my/one.pyc"
+py_installed --not "$inst/my/one.pyo"
 $MAKE uninstall
-test ! -e "$inst/your/two.py"
-test ! -e "$inst/your/two.pyc"
-test ! -e "$inst/your/two.pyo"
+py_installed --not "$inst/your/two.py"
+py_installed --not "$inst/your/two.pyc"
+py_installed --not "$inst/your/two.pyo"
 
 ../configure --prefix=$cwd/"$inst" one=1
 $MAKE install
-test ! -e "$inst/your/two.py"
-test ! -e "$inst/your/two.pyc"
-test ! -e "$inst/your/two.pyo"
-test -f "$inst/my/one.py"
-test -f "$inst/my/one.pyc"
-test -f "$inst/my/one.pyo"
+py_installed --not "$inst/your/two.py"
+py_installed --not "$inst/your/two.pyc"
+py_installed --not "$inst/your/two.pyo"
+test -f            "$inst/my/one.py"
+py_installed       "$inst/my/one.pyc"
+py_installed       "$inst/my/one.pyo"
 $MAKE uninstall
-test ! -e "$inst/my/one.py"
-test ! -e "$inst/my/one.pyc"
-test ! -e "$inst/my/one.pyo"
+py_installed --not "$inst/my/one.py"
+py_installed --not "$inst/my/one.pyc"
+py_installed --not "$inst/my/one.pyo"
 
 $MAKE disttest
 
diff --git a/t/python11.sh b/t/python11.sh
index e86d30e..a22826c 100755
--- a/t/python11.sh
+++ b/t/python11.sh
@@ -19,6 +19,9 @@
 # Python is not required for this test.
 . ./defs || exit 1
 
+# We don't want to allow user overrides in this test.
+PYTHON=; unset PYTHON
+
 cat >>configure.ac <<'EOF'
 m4_define([_AM_PYTHON_INTERPRETER_LIST], [IShouldNotExist1 IShouldNotExist2])
 AM_PATH_PYTHON
diff --git a/t/python12.sh b/t/python12.sh
index 898c673..12dca5d 100755
--- a/t/python12.sh
+++ b/t/python12.sh
@@ -36,19 +36,19 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE --add-missing
 
-instdir=$(pwd)/inst
+destdir=$(pwd)/inst
 mkdir inst build
 cd build
 ../configure --prefix="/usr"
-$MAKE install DESTDIR=$instdir
+$MAKE install DESTDIR=$destdir
 
 # Perfunctory test that the files were created.
-test -f "$instdir/usr/share/my/my.py"
-test -f "$instdir/usr/share/my/my.pyc"
-test -f "$instdir/usr/share/my/my.pyo"
+test -f "$destdir/usr/share/my/my.py"
+pyo=$(pyc_location -p "$destdir/usr/share/my/my.pyo")
+pyc=$(pyc_location -p "$destdir/usr/share/my/my.pyc")
 
 # If DESTDIR has made it into the byte compiled files, fail the test.
-$FGREP "$instdir" "$instdir/usr/share/my/my.pyo" \
-                  "$instdir/usr/share/my/my.pyc" && exit 1
+st=0; $FGREP "$destdir" "$pyc" "$pyo" || st=$?
+test $st -eq 1
 
 :
diff --git a/t/python3.sh b/t/python3.sh
index 8667cf9..934be21 100755
--- a/t/python3.sh
+++ b/t/python3.sh
@@ -40,8 +40,8 @@ mkdir build
 cd build
 ../configure --prefix="$(pwd)/inst"
 $MAKE install
-test -f inst/my/one.py
-test -f inst/my/one.pyc
-test -f inst/my/one.pyo
+py_installed inst/my/one.py
+py_installed inst/my/one.pyc
+py_installed inst/my/one.pyo
 
 :


hooks/post-receive
-- 
GNU Automake



reply via email to

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