summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2015-12-17 23:23:53 +0100
committerMichał Górny <mgorny@gentoo.org>2015-12-31 15:52:03 +0100
commitf202e56a0ead3feba43041ee4d5cc45f93c86d85 (patch)
tree538853316cc30823f7732447672cf70c0d0aa10a
parentdev-db/mongodb: drop 2.4 series (diff)
downloadgentoo-f202e56a0ead3feba43041ee4d5cc45f93c86d85.tar.gz
gentoo-f202e56a0ead3feba43041ee4d5cc45f93c86d85.tar.bz2
gentoo-f202e56a0ead3feba43041ee4d5cc45f93c86d85.zip
python-r1.eclass: Introduce python_gen_impl_dep
Add a python_gen_impl_dep() that serves the purpose of generating custom dependencies on the Python interpreter (like PYTHON_DEPS). The function provides ability to request dependencies with another USE dependency string (different than global PYTHON_REQ_USE) and limit the dependencies to subset of supported implementations.
-rw-r--r--eclass/python-r1.eclass52
1 files changed, 52 insertions, 0 deletions
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 76fd944f0b8c..610657776d20 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -383,6 +383,58 @@ 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_targets_python2_7? (
+# dev-lang/python:2.7[xml(+)] )
+# python_targets_pypy? (
+# dev-python/pypy[xml(+)] ) )"
+# @CODE
+python_gen_impl_dep() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local impl pattern
+ local matches=()
+
+ 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+=( "python_targets_${impl}? ( ${PYTHON_PKG_DEP} )" )
+ break
+ fi
+ done
+ done
+
+ echo "${matches[@]}"
+}
+
# @ECLASS-VARIABLE: BUILD_DIR
# @DESCRIPTION:
# The current build directory. In global scope, it is supposed to