public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: python@gentoo.org, "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH 2/5] python-single-r1.eclass: Add python_gen_impl_dep, alike in python-r1
Date: Wed, 23 Dec 2015 17:44:37 +0100	[thread overview]
Message-ID: <1450889080-1920-3-git-send-email-mgorny@gentoo.org> (raw)
In-Reply-To: <1450889080-1920-1-git-send-email-mgorny@gentoo.org>

---
 eclass/python-single-r1.eclass | 58 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index 4d5026f..9e80866 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
-- 
2.6.4



  parent reply	other threads:[~2015-12-23 16:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-23 16:44 [gentoo-dev] [PATCH 0/5] python-r1 suite: python_gen_impl_dep() function Michał Górny
2015-12-23 16:44 ` [gentoo-dev] [PATCH 1/5] python-r1.eclass: Introduce python_gen_impl_dep Michał Górny
2015-12-23 16:44 ` Michał Górny [this message]
2015-12-23 16:44 ` [gentoo-dev] [PATCH 3/5] app-emulation/xen-tools: Make use of new python_gen_impl_dep function Michał Górny
2015-12-24 16:21   ` Doug Goldstein
2015-12-23 16:44 ` [gentoo-dev] [PATCH 4/5] dev-python/django: Make use of the " Michał Górny
2015-12-23 16:44 ` [gentoo-dev] [PATCH 5/5] sys-apps/portage: " Michał Górny
2015-12-24 15:30 ` [gentoo-dev] [PATCH 0/5] python-r1 suite: python_gen_impl_dep() function Peter Stuge
2015-12-29 17:40   ` Michał Górny
2015-12-31 14:52 ` Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1450889080-1920-3-git-send-email-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    --cc=python@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox