summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2015-12-22 23:18:16 +0100
committerMichał Górny <mgorny@gentoo.org>2015-12-31 15:52:03 +0100
commit7c2f42d899fd102798dcf4e30343aba20fd3bb3d (patch)
treeb6eb8768e67553bb9fae7e59ca398e49a7df83b6 /eclass/python-single-r1.eclass
parentpython-r1.eclass: Introduce python_gen_impl_dep (diff)
downloadgentoo-7c2f42d899fd102798dcf4e30343aba20fd3bb3d.tar.gz
gentoo-7c2f42d899fd102798dcf4e30343aba20fd3bb3d.tar.bz2
gentoo-7c2f42d899fd102798dcf4e30343aba20fd3bb3d.zip
python-single-r1.eclass: Add python_gen_impl_dep, alike in python-r1
Diffstat (limited to 'eclass/python-single-r1.eclass')
-rw-r--r--eclass/python-single-r1.eclass58
1 files changed, 58 insertions, 0 deletions
diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index 4d5026fc9b31..9e80866bfb51 100644
--- a/eclass/python-single-r1.eclass
+++ b/eclass/python-single-r1.eclass
@@ -411,6 +411,64 @@ python_gen_cond_dep() {
echo "${matches[@]}"
}
+# @FUNCTION: python_gen_impl_dep
+# @USAGE: [<requested-use-flags> [<impl-pattern>...]]
+# @DESCRIPTION:
+# Output a dependency on Python implementations with the specified USE
+# dependency string appended, or no USE dependency string if called
+# without the argument (or with empty argument). If any implementation
+# patterns are passed, the output dependencies will be generated only
+# for the implementations matching them.
+#
+# Use this function when you need to request different USE flags
+# on the Python interpreter depending on package's USE flags. If you
+# only need a single set of interpreter USE flags, just set
+# PYTHON_REQ_USE and use ${PYTHON_DEPS} globally.
+#
+# Example:
+# @CODE
+# PYTHON_COMPAT=( python{2_7,3_{3,4}} pypy )
+# RDEPEND="foo? ( $(python_gen_impl_dep 'xml(+)') )"
+# @CODE
+#
+# It will cause the variable to look like:
+# @CODE
+# RDEPEND="foo? (
+# python_single_target_python2_7? (
+# dev-lang/python:2.7[xml(+)] )
+# python_single_target_pypy? (
+# dev-python/pypy[xml(+)] ) )"
+# @CODE
+python_gen_impl_dep() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local impl pattern
+ local matches=()
+
+ if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
+ flag_prefix=python_targets
+ else
+ flag_prefix=python_single_target
+ fi
+
+ local PYTHON_REQ_USE=${1}
+ shift
+
+ local patterns=( "${@-*}" )
+ for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
+ for pattern in "${patterns[@]}"; do
+ if [[ ${impl} == ${pattern} ]]; then
+ local PYTHON_PKG_DEP
+ python_export "${impl}" PYTHON_PKG_DEP
+ matches+=( "${flag_prefix}_${impl}? ( ${PYTHON_PKG_DEP} )" )
+ break
+ fi
+ done
+ done
+
+ echo "${matches[@]}"
+}
+
# @FUNCTION: python_setup
# @DESCRIPTION:
# Determine what the selected Python implementation is and set