If you passed the option --prefer-make
to pyconf,
Makefile.in will contain all of the installation logic for your
package. It is highly recommended that you be familiar with basic Make
usage. See the see Make manual.
By default, Makefile.in will contain the logic necessary to
install a basic Python package consisting of one or more modules. The
primary customization may be performed via the variables found at the
beginning of the file: PYPACKAGES
, PYPACKAGE_ROOT
,
SCRIPTS
, PKG_DATA
, DATA
, and DATA_ROOT
.
PYPACKAGES
should contain a space-separated list of all of the
Python modules in your package (i.e. top-level directories containing
a __init__.py file). When your package is installed to the
user's computer, these modules will be stored in the Python package
directory (generally
$prefix/lib/python$version/{site,dist}-packages/). If the
modules are contained in a sub-directory, say src, of your
source directory, you may set the PYPACKAGE_ROOT
variable to
that directory.
PYPACKAGES = foo bar PYPACKAGE_ROOT = src
In this example, there are two modules to install: “foo” and “bar”. The modules are to be found under the src directory; thus, for example, module “foo” is to be found at src/foo.
The directories listed under PYPACKAGES
will only have their
Python files installed. If your modules depend on other, non-Python
data files, you may list these under the PKG_DATA
variable. Data files should be listed relative to their parent
module. Thus, if module “foo” contains a file called bar.dat,
set PKG_DATA = foo/bar.dat
.
Other data files, which are not specific to any of the Python modules,
may be specified under the DATA
variable. As before, if your
data files are all stored under a particular sub-directory, you may
specify it in DATA_ROOT
. Files listed under DATA
are
installed to the package's data directory, which is typically
/usr/local/share/$package).
Finally, if your package has any scripts to install, list them under
the SCRIPTS
variable. They should be listed as files relative
to the directory containing Makefile.in. Thus, if your script
baz is located in the sub-directory bin, you would set
SCRIPTS = bin/baz
.
One particular advantage of writing the installation logic in Make is the ease with which you may work with non-Python code in your project, such as extensions written in C. How these recipes are to be written is dependent upon the build requirements of this code, and you are thus referred to the see Make manual. Any installation recipes should be given their own targets and made as prerequisites of the “install” target.