diff options
author | Michał Górny <mgorny@gentoo.org> | 2013-09-24 19:53:06 +0000 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2013-09-24 19:53:06 +0000 |
commit | 4446a7887e9f9b9127ba7b9757c535d78456951d (patch) | |
tree | fe405cba350e40e03235e18084338a3e7dc016d8 /eclass/python-any-r1.eclass | |
parent | Add back stable version that was over zealously removed. (diff) | |
download | gentoo-2-4446a7887e9f9b9127ba7b9757c535d78456951d.tar.gz gentoo-2-4446a7887e9f9b9127ba7b9757c535d78456951d.tar.bz2 gentoo-2-4446a7887e9f9b9127ba7b9757c535d78456951d.zip |
Introduce python_gen_any_dep to generate any-of dependencies matching python_check_deps() code.
Diffstat (limited to 'eclass/python-any-r1.eclass')
-rw-r--r-- | eclass/python-any-r1.eclass | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass index 3be995f5946c..c5c65a3fd69f 100644 --- a/eclass/python-any-r1.eclass +++ b/eclass/python-any-r1.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/python-any-r1.eclass,v 1.13 2013/08/01 12:49:42 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/python-any-r1.eclass,v 1.14 2013/09/24 19:53:06 mgorny Exp $ # @ECLASS: python-any-r1 # @MAINTAINER: @@ -156,6 +156,67 @@ _python_build_set_globals # python_targets_python2_7(-)?,python_single_target_python2_7(+)? # @CODE +# @FUNCTION: python_gen_any_dep +# @USAGE: <dependency-block> +# @DESCRIPTION: +# 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: +# @CODE +# 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}]"; } +# } +# @CODE +# +# Example value: +# @CODE +# || ( +# ( +# 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(+)?] ) +# ) +# ) +# @CODE +python_gen_any_dep() { + debug-print-function ${FUNCNAME} "${@}" + + local depstr=${1} + [[ ${depstr} ]] || die "No dependency string provided" + + local PYTHON_PKG_DEP out= + for i in "${_PYTHON_ALL_IMPLS[@]}"; do + has "${i}" "${PYTHON_COMPAT[@]}" || continue + + local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)" + python_export "${i}" PYTHON_PKG_DEP + + local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}} + out="( ${PYTHON_PKG_DEP} ${i_depstr} ) ${out}" + done + echo "|| ( ${out})" +} + # @FUNCTION: _python_EPYTHON_supported # @USAGE: <epython> # @INTERNAL |