Tag
Hash :
fb55cab8
Author :
Date :
2001-05-13T23:31:05
2001-05-13 James Henstridge <james@daa.com.au> * m4/python.m4 (AM_PATH_PYTHON): Added more names for python. Point pythondir at site-packages directory. Rename PYTHON_SITE_PACKAGE to pkgpythondir. Rename PYTHON_SITE_EXEC to pyexecdir. Removed package/module argument. Removed PYTHON_SITE_INSTALL. Added version checking.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
## ------------------------
## Python file handling
## From Andrew Dalke
## Updated by James Henstridge
## ------------------------
# AM_PATH_PYTHON([MINIMUM-VERSION])
# Adds support for distributing Python modules and packages. To
# install modules, copy them to $(pythondir), using the python_PYTHON
# automake variable. To install a package with the same name as the
# automake package, install to $(pkgpythondir), or use the
# pkgpython_PYTHON automake variable.
# The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
# locations to install python extension modules (shared libraries).
# Another macro is required to find the appropriate flags to compile
# extension modules.
# If your package is configured with a different prefix to python,
# users will have to add the install directory to the PYTHONPATH
# environment variable, or create a .pth file (see the python
# documentation for details).
# If the MINIUMUM-VERSION argument is passed, AM_PATH_PYTHON will
# cause an error if the version of python installed on the system
# doesn't meet the requirement. MINIMUM-VERSION should consist of
# numbers and dots only.
AC_DEFUN([AM_PATH_PYTHON],
[
dnl Find a version of Python. I could check for python versions 1.4
dnl or earlier, but the default installation locations changed from
dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
dnl in 1.5, and I don't want to maintain that logic.
AC_PATH_PROG(PYTHON, python python2.1 python2.0 python1.6 python1.5)
dnl should we do the version check?
ifelse([$1],[],,[
AC_MSG_CHECKING(if Python version >= $1)
changequote(<<, >>)dnl
prog="
import sys, string
minver = '$1'
pyver = string.split(sys.version)[0] # first word is version string
# split strings by '.' and convert to numeric
minver = map(string.atoi, string.split(minver, '.'))
pyver = map(string.atoi, string.split(pyver, '.'))
# we can now do comparisons on the two lists:
if pyver >= minver:
sys.exit(0)
else:
sys.exit(1)"
changequote([, ])dnl
if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
then
AC_MSG_RESULT(okay)
else
AC_MSG_ERROR(too old)
fi
])
AC_MSG_CHECKING([local Python configuration])
dnl Query Python for its version number. Getting [:3] seems to be
dnl the best way to do this; it's what "site.py" does in the standard
dnl library. Need to change quote character because of [:3]
AC_SUBST(PYTHON_VERSION)
changequote(<<, >>)dnl
PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"`
changequote([, ])dnl
dnl Use the values of $prefix and $exec_prefix for the corresponding
dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
dnl distinct variables so they can be overridden if need be. However,
dnl general consensus is that you shouldn't need this ability.
AC_SUBST(PYTHON_PREFIX)
PYTHON_PREFIX='${prefix}'
AC_SUBST(PYTHON_EXEC_PREFIX)
PYTHON_EXEC_PREFIX='${exec_prefix}'
dnl At times (like when building shared libraries) you may want
dnl to know which OS platform Python thinks this is.
AC_SUBST(PYTHON_PLATFORM)
PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
dnl Set up 4 directories:
dnl pythondir -- where to install python scripts. This is the
dnl site-packages directory, not the python standard library
dnl directory like in previous automake betas. This behaviour
dnl is more consistent with lispdir.m4 for example.
dnl
dnl Also, if the package prefix isn't the same as python's prefix,
dnl then the old $(pythondir) was pretty useless.
AC_SUBST(pythondir)
pythondir=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
dnl more consistent with the rest of automake.
dnl Maybe this should be put in python.am?
AC_SUBST(pkgpythondir)
pkgpythondir=\${pythondir}/$PACKAGE
dnl pyexecdir -- directory for installing python extension modules
dnl (shared libraries) Was PYTHON_SITE_EXEC in previous betas.
AC_SUBST(pyexecdir)
pyexecdir=$PYTHON_EXEC_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
dnl Maybe this should be put in python.am?
AC_SUBST(pkgpyexecdir)
pkgpyexecdir=\${pyexecdir}/$PACKAGE
AC_MSG_RESULT([looks good])
])