python-vars.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #! /bin/sh
  2. # Copyright (C) 2011-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. # Check that AM_PATH_PYTHON correctly sets all the output variables
  17. # advertised in the manual.
  18. required=python
  19. . test-init.sh
  20. # In case the user's config.site defines pythondir or pyexecdir.
  21. CONFIG_SITE=/dev/null; export CONFIG_SITE
  22. # Update the definition below if the documentation changes.
  23. # Note that the value of the 'pythondir' and 'pyexecdir' variables can
  24. # vary among different python installations, so we need more relaxed
  25. # and ad-hoc checks for them. Also, more proper "functional" checks
  26. # on them should be done in the 'python-virtualenv.sh' test.
  27. PYTHON_VERSION=$($PYTHON -c 'import sys; print(sys.version[:3])') || exit 1
  28. PYTHON_PLATFORM=$($PYTHON -c 'import sys; print(sys.platform)') || exit 1
  29. PYTHON_EXEC_PREFIX='${exec_prefix}'
  30. PYTHON_PREFIX='${prefix}'
  31. pkgpythondir="\${pythondir}/$me"
  32. pkgpyexecdir="\${pyexecdir}/$me"
  33. pyvars='PYTHON_VERSION PYTHON_PLATFORM PYTHON_PREFIX PYTHON_EXEC_PREFIX
  34. pkgpythondir pkgpyexecdir'
  35. cat >> configure.ac << 'END'
  36. AC_CONFIG_FILES([vars-got pythondir pyexecdir])
  37. AM_PATH_PYTHON
  38. AC_OUTPUT
  39. END
  40. cat > my.py << 'END'
  41. def my():
  42. return 1
  43. END
  44. cat > Makefile.am << 'END'
  45. python_PYTHON = my.py
  46. EXTRA_DIST = vars-exp
  47. check-local: test-in test-am
  48. .PHONY: test-in test-am
  49. test-in:
  50. cat pythondir
  51. case `cat pythondir` in '$${prefix}'/*);; *) exit 1;; esac
  52. cat pyexecdir
  53. case `cat pyexecdir` in '$${exec_prefix}'/*);; *) exit 1;; esac
  54. cat $(srcdir)/vars-exp
  55. cat $(builddir)/vars-got
  56. diff $(srcdir)/vars-exp $(builddir)/vars-got
  57. ## Note: this target's rules will be extended in the "for" loop below.
  58. test-am:
  59. case '$(pythondir)' in '$(prefix)'/*);; *) exit 1;; esac
  60. case '$(pyexecdir)' in '$(exec_prefix)'/*);; *) exit 1;; esac
  61. END
  62. echo @pythondir@ > pythondir.in
  63. echo @pyexecdir@ > pyexecdir.in
  64. : > vars-exp
  65. : > vars-got.in
  66. for var in $pyvars; do
  67. eval val=\$$var
  68. echo "var=$val" >> vars-exp
  69. echo "var=@$var@" >> vars-got.in
  70. echo "${tab}test x'\$($var)' = x'$val'" >> Makefile.am
  71. done
  72. cat Makefile.am
  73. cat vars-got.in
  74. $ACLOCAL
  75. $AUTOMAKE --add-missing
  76. for var in pythondir pyexecdir $pyvars; do
  77. grep "^$var *=" Makefile.in
  78. done
  79. $AUTOCONF
  80. ./configure PYTHON="$PYTHON"
  81. $MAKE test-in test-am
  82. $MAKE distcheck
  83. :