Gentoo Development Guide

PYTHON-ANY-R1

Section: portage (5)
Updated: Apr 2014
Index Return to Main Contents
 

NAME

python-any-r1 - An eclass for packages having build-time dependency on Python.  

DESCRIPTION

A minimal eclass for packages which need any Python interpreter installed without a need for explicit choice and invariability. This usually involves packages requiring Python at build-time but having no other relevance to it.

This eclass provides a minimal PYTHON_DEPS variable with a dependency string on any of the supported Python implementations. It also exports pkg_setup() which finds the best supported implementation and sets it as the active one.

Optionally, you can define a python_check_deps() function. It will be called by the eclass with EPYTHON set to each matching Python implementation and it is expected to check whether the implementation fulfills the package requirements. You can use the locally exported PYTHON_USEDEP to check USE-dependencies of relevant packages. It should return a true value (0) if the Python implementation fulfills the requirements, a false value (non-zero) otherwise.

Please note that python-any-r1 will always inherit python-utils-r1 as well. Thus, all the functions defined there can be used in the packages using python-any-r1, and there is no need ever to inherit both.

For more information, please see the python-r1 Developer's Guide: http://www.gentoo.org/proj/en/Python/python-r1/dev-guide.xml  

FUNCTIONS

python_gen_any_dep <dependency-block>
Generate an any-of dependency that enforces a version match between the Python interpreter and Python packages. <dependency-block> needs to list one or more dependencies with verbatim '${PYTHON_USEDEP}' references (quoted!) that will get expanded inside the function.

This should be used along with an appropriate python_check_deps() that checks which of the any-of blocks were matched.

Example use:

DEPEND="$(python_gen_any_dep '
dev-python/foo[${PYTHON_USEDEP}]
|| ( dev-python/bar[${PYTHON_USEDEP}]
        dev-python/baz[${PYTHON_USEDEP}] )')"

python_check_deps() {
has_version "dev-python/foo[${PYTHON_USEDEP}]" \
        && { has_version "dev-python/bar[${PYTHON_USEDEP}]" \
                || has_version "dev-python/baz[${PYTHON_USEDEP}]"; }
}

Example value:

|| (
(
        dev-lang/python:2.7
        dev-python/foo[python_targets_python2_7(-)?,python_single_target_python2_7(+)?]
        || ( dev-python/bar[python_targets_python2_7(-)?,python_single_target_python2_7(+)?]
                dev-python/baz[python_targets_python2_7(-)?,python_single_target_python2_7(+)?] )
)
(
        dev-lang/python:2.6
        dev-python/foo[python_targets_python2_6(-)?,python_single_target_python2_6(+)?]
        || ( dev-python/bar[python_targets_python2_6(-)?,python_single_target_python2_6(+)?]
                dev-python/baz[python_targets_python2_6(-)?,python_single_target_python2_6(+)?] )
)
)
python_setup
Determine what the best installed (and supported) Python implementation is, and set the Python build environment up for it.

This function will call python_check_deps() if defined.

python-any-r1_pkg_setup
Runs python_setup during from-source installs.

In a binary package installs is a no-op. If you need Python in pkg_* phases of a binary package, call python_setup directly.

 

ECLASS VARIABLES

PYTHON_COMPAT (REQUIRED)
This variable contains a list of Python implementations the package supports. It must be set before the `inherit' call. It has to be an array.

Example:

PYTHON_COMPAT=( python{2_5,2_6,2_7} )
PYTHON_REQ_USE
The list of USEflags required to be enabled on the Python implementations, formed as a USE-dependency string. It should be valid for all implementations in PYTHON_COMPAT, so it may be necessary to use USE defaults.

Example:

PYTHON_REQ_USE="gdbm,ncurses(-)?"

It will cause the Python dependencies to look like:

|| ( dev-lang/python:X.Y[gdbm,ncurses(-)?] ... )
PYTHON_DEPS
This is an eclass-generated Python dependency string for all implementations listed in PYTHON_COMPAT.

Any of the supported interpreters will satisfy the dependency.

Example use:

DEPEND="${RDEPEND}
${PYTHON_DEPS}"

Example value:

|| ( dev-lang/python:2.7[gdbm]
        dev-lang/python:2.6[gdbm] )
PYTHON_USEDEP
An eclass-generated USE-dependency string for the currently tested implementation. It is set locally for python_check_deps() call.

The generate USE-flag list is compatible with packages using python-r1, python-single-r1 and python-distutils-ng eclasses. It must not be used on packages using python.eclass.

Example use:

python_check_deps() {
has_version "dev-python/foo[${PYTHON_USEDEP}]"
}

Example value:

python_targets_python2_7(-)?,python_single_target_python2_7(+)?
 

AUTHORS

Author: Michał Górny <mgorny@gentoo.org>
Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
 

MAINTAINERS

Python team <python@gentoo.org>
 

REPORTING BUGS

Please report bugs via http://bugs.gentoo.org/  

FILES

/usr/portage/eclass/python-any-r1  

SEE ALSO

ebuild(5)
http://sources.gentoo.org/eclass/python-any-r1?view=log


 

Index

NAME
DESCRIPTION
FUNCTIONS
ECLASS VARIABLES
AUTHORS
MAINTAINERS
REPORTING BUGS
FILES
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 03:25:11 GMT, April 17, 2014