python-too-old.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #! /bin/sh
  2. # Copyright (C) 2003-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Test detection of too old Python, also forcing the python to use.
  17. # See also related test 't/python-am-path-missing.sh'.
  18. am_create_testdir=empty
  19. required=python
  20. . test-init.sh
  21. py_too_old ()
  22. {
  23. ./configure ${1+"PYTHON=$1"} >stdout 2>stderr && {
  24. cat stdout
  25. cat stderr >&2
  26. exit 1
  27. }
  28. cat stdout
  29. cat stderr >&2
  30. grep "whether $1 version is >= 9999\\.9\\.\\.\\. no *$" stdout
  31. grep '[Pp]ython interpreter is too old' stderr
  32. }
  33. saved_PYTHON=$PYTHON; export saved_PYTHON
  34. unset PYTHON
  35. cat > configure.ac <<END
  36. AC_INIT([$me], [1.0])
  37. # Hopefully the Python team will never release such a version.
  38. AM_PATH_PYTHON([9999.9])
  39. END
  40. $ACLOCAL
  41. $AUTOCONF
  42. py_too_old python
  43. mkdir bin
  44. cat > bin/my-python << 'END'
  45. #! /bin/sh
  46. exec $saved_PYTHON ${1+"$@"}
  47. END
  48. chmod a+x bin/my-python
  49. PATH=$(pwd)/bin$PATH_SEPARATOR$PATH
  50. py_too_old my-python
  51. :