python-missing.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 missing Python.
  17. # See also related test t/python-am-path-missing-2.sh (which requires
  18. # an actual python program).
  19. am_create_testdir=empty
  20. # An actual python is *not* required in this test.
  21. . test-init.sh
  22. unset PYTHON
  23. cat > configure.ac <<END
  24. AC_INIT([$me], [1.0])
  25. m4_include([mypy.m4])
  26. AC_OUTPUT
  27. END
  28. echo AM_PATH_PYTHON > mypy.m4
  29. $ACLOCAL
  30. $AUTOCONF
  31. # Simulate no Python.
  32. ./configure PYTHON=: 2>stderr && { cat stderr >&2; exit 1; }
  33. cat stderr >&2
  34. grep 'no suitable Python interpreter found' stderr
  35. # Again, but from the environment this time.
  36. env PYTHON=: ./configure 2>stderr && { cat stderr >&2; exit 1; }
  37. cat stderr >&2
  38. grep 'no suitable Python interpreter found' stderr
  39. # Now try using a custom ACTION-IF-NOT-FOUND.
  40. echo 'AM_PATH_PYTHON(,, [echo "$PYTHON" > py])' > mypy.m4
  41. $AUTOCONF --force
  42. ./configure PYTHON=:
  43. test x"$(cat py)" = x:
  44. # Now try requiring a version.
  45. rm -rf autom4te*.cache # Will have to re-run aclocal.
  46. # Hopefully the Python team will never release such a version :-)
  47. echo 'AM_PATH_PYTHON([9999.9], [])' > mypy.m4
  48. # The "--force" options (here and below) are truly needed to avoid
  49. # potential timestamp races. See automake bug#12210.
  50. $ACLOCAL --force
  51. $AUTOCONF --force
  52. ./configure >stdout 2>stderr && {
  53. cat stdout
  54. cat stderr >&2
  55. exit 1
  56. }
  57. cat stdout
  58. cat stderr >&2
  59. $EGREP 'checking for a Python interpreter with version >= 9999\.9\.\.\. no(ne)? *$' stdout
  60. grep 'no suitable Python interpreter found' stderr
  61. # Now try requiring a version and using a custom ACTION-IF-NOT-FOUND.
  62. echo 'AM_PATH_PYTHON([9999.9], [], [echo "$PYTHON" > py])' > mypy.m4
  63. $AUTOCONF --force
  64. ./configure
  65. test x"$(cat py)" = x:
  66. :