Automake provides support for Python compilation with the PYTHON
primary.
Any files listed in a _PYTHON
variable will be byte-compiled
with py-compile at install time. py-compile
actually creates both standard (.pyc) and byte-compiled
(.pyo) versions of the source files. Note that because
byte-compilation occurs at install time, any files listed in
noinst_PYTHON
will not be compiled. Python source files are
included in the distribution by default.
Automake ships with an Autoconf macro called AM_PATH_PYTHON
that
will determine some Python-related directory variables (see below). If
you have called AM_PATH_PYTHON
from configure.ac, then you
may use the following variables to list you Python source files in your
variables: python_PYTHON
, pkgpython_PYTHON
,
pyexecdir_PYTHON
, pkgpyexecdir_PYTHON
, depending where you
want your files installed.
Search a Python interpreter on the system. This macro takes three optional arguments. The first argument, if present, is the minimum version of Python required for this package:
AM_PATH_PYTHON
will skip any Python interpreter that is older than VERSION. If an interpreter is found and satisfies VERSION, then ACTION-IF-FOUND is run. Otherwise, ACTION-IF-NOT-FOUND is run.If ACTION-IF-NOT-FOUND is not specified, the default is to abort configure. This is fine when Python is an absolute requirement for the package. Therefore if Python >= 2.2 is only optional to the package,
AM_PATH_PYTHON
could be called as follows.AM_PATH_PYTHON(2.2,, :)
AM_PATH_PYTHON
creates the following output variables based on the Python installation found during configuration.
PYTHON
Assuming ACTION-IF-NOT-FOUND is used (otherwise ./configure
will abort if Python is absent), the value of PYTHON
can be used
to setup a conditional in order to disable the relevant part of a build
as follows.
AM_PATH_PYTHON(,, :) AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
PYTHON_VERSION
PYTHON_PREFIX
PYTHON_EXEC_PREFIX
PYTHON_PLATFORM
pythondir
pkgpythondir
pythondir
that is named after the
package. That is, it is $(pythondir)/$(PACKAGE). It is provided
as a convenience.
pyexecdir
pkgpyexecdir
All these directory variables have values that start with either ${prefix} or ${exec_prefix} unexpanded. This works fine in Makefiles, but it makes these variables hard to use in configure. This is mandated by the GNU coding standards, so that the user can run make prefix=/foo install. The Autoconf manual has a section with more details on this topic (see Installation Directory Variables (The Autoconf Manual)). See also Hard-Coded Install Paths.