diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-11-21 14:13:02 +0100 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-11-21 14:13:02 +0100 |
commit | cb6a19d9d0c46ddf03b2494333bed2c3d7dc1e15 (patch) | |
tree | 721527736aebfef6dc894cbf4306a565f04a3626 /t/ax/am-test-lib.sh | |
parent | ab49d2bc115ba121b00ac06229d4044a004f67e9 (diff) | |
parent | 8d1a542296ca5d9137644387ebe1611239e41018 (diff) | |
download | automake-cb6a19d9d0c46ddf03b2494333bed2c3d7dc1e15.tar.gz |
Merge branch 'maint'
* maint:
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)
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 't/ax/am-test-lib.sh')
-rw-r--r-- | t/ax/am-test-lib.sh | 66 |
1 files changed, 63 insertions, 3 deletions
diff --git a/t/ax/am-test-lib.sh b/t/ax/am-test-lib.sh index d3351d2d0..6d7c69b04 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_ () { @@ -654,9 +713,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 |