InstallPython

Define function install_python() to (optionally generate and) invoke a Python distutils setup.py script.

install_python

Invoke Python distutils functionality to install Python files.

install_python(SETUP_PY <setup.py> [NO_INSTALL])
install_python([GENERATE_SETUP_PY] [NO_INSTALL] [<gen-options>])
install_python(SETUP_PY <setup.py> [NO_INSTALL])

Invoke <setup.py> to build and install Python package files.

install_python(GENERATE_SETUP_PY [NO_INSTALL] [<gen-options>])

Generate a setup.py file with information provided by <gen-options>:

DATA_FILES DIR <dir> <file> ...

Specify <file> ...` for inclusion in the package in non-package subdirectory ``<dir>.

MODULES <module> ...

Specify single Python files for use as modules (with import). They will be installed in lib/

NAME <name>

The name of the Python package to be installed (default CETMODULES_CURRENT_PROJECT_NAME).

PACKAGES <package> ...

Specify packages to be installed under lib/, with pkg1.pkg2 installed in pkg1/pkg2.

PACKAGE_DATA  { ROOT | PKG <pkg> } <file> ...

Install non-Python <file> ... in the top level package (ROOT) or with package <pkg>.

SCRIPTS <script> ...

Install executable Python script <script> ... in bin/

If required, the same file may be both a script and a module.

SETUP_ARGS <arg> ...

Pass <arg> ... to the distutils setup() command, if required.

SETUP_PREAMBLE <preamble>

Place <preamble> at the beginning of the generated setup.py file prior to the invocation of setup().

VERSION <version>

Specify the package version (default CETMODULES_CURRENT_PROJECT_VERSION).

Example

For a directory containing the following files:

  • README.txt

  • test.py

  • test2.py

  • test3.py

  • pkg1/README-pkg1.txt

  • pkg1/__init__.py

  • pkg1/bill.py

  • pkg1/pkg2/README-pkg2.txt

  • pkg1/pkg2/__init__.py

  • pkg1/pkg2/fred.py

The command:

install_python(SCRIPTS test.py test2.py test3.py
               MODULES test2
               PACKAGES pkg1 pkg1.pkg2
               PACKAGE_DATA ROOT README.txt PKG pkg1 README-pkg1.txt
               DATA_FILES
               DIR doc README.txt pkg1/README-pkg1.txt pkg1/pkg2/README-pkg2.txt
               DIR etc README.txt pkg1/README-pkg1.txt pkg1/pkg2/README-pkg2.txt)

will produce the following directory structure under CETMODULES_CURRENT_PROJECT_BINARY_DIR:

  • bin/test.py

  • bin/test2.py

  • bin/test3.py

  • doc/README.txt

  • doc/README-pkg1.txt

  • doc/README-pkg2.txt

  • etc/README.txt

  • etc/README-pkg1.txt

  • etc/README-pkg2.txt

  • lib/art-1.09.02-py2.7.egg-info

  • lib/pkg1/__init__.py

  • lib/pkg1/__init__.pyc

  • lib/pkg1/bill.py

  • lib/pkg1/bill.pyc

  • lib/pkg1/pkg2/__init__.py

  • lib/pkg1/pkg2/__init__.pyc

  • lib/pkg1/pkg2/fred.py

  • lib/pkg1/pkg2/fred.pyc

  • lib/pkg1/README-pkg1.txt

  • lib/test2.py

  • lib/test2.pyc

After install, the same files will be visible under the corresponding directory in the installed product.