public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-python] [PATCH 1/2] Introduce python_gen_usedep & python_gen_useflags for special deps.
@ 2012-12-19 21:00 Michał Górny
  2012-12-19 21:00 ` [gentoo-python] [PATCH 2/2] Use python_gen_*() functions to make the deps simpler Michał Górny
  0 siblings, 1 reply; 2+ messages in thread
From: Michał Górny @ 2012-12-19 21:00 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

For example, when a particular dependency applies only to some
of the supported Python implementations.

The next patch provides example use for them.
---
 gx86/eclass/python-r1.eclass | 78 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
index aa9153e..40ce68b 100644
--- a/gx86/eclass/python-r1.eclass
+++ b/gx86/eclass/python-r1.eclass
@@ -177,6 +177,84 @@ _python_set_globals() {
 }
 _python_set_globals
 
+# @FUNCTION: python_gen_usedep
+# @USAGE: pattern [...]
+# @DESCRIPTION:
+# Output a USE dependency string for Python implementations which
+# are both in PYTHON_COMPAT and match any of the patterns passed
+# as parameters to the function.
+#
+# When all implementations are requested, please use ${PYTHON_USEDEP}
+# instead. Please also remember to set an appropriate REQUIRED_USE
+# to avoid ineffective USE flags.
+#
+# Example:
+# @CODE
+# PYTHON_COMPAT=( python{2_7,3_2} )
+# DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep python2*)] )"
+# @CODE
+#
+# It will cause the dependency to look like:
+# @CODE
+# DEPEND="doc? ( dev-python/epydoc[python_targets_python2_7?] )"
+# @CODE
+python_gen_usedep() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local impl pattern
+	local matches=()
+
+	for impl in "${PYTHON_COMPAT[@]}"; do
+		for pattern; do
+			if [[ ${impl} == ${pattern} ]]; then
+				matches+=(
+					"python_targets_${impl}?"
+					"-python_single_target_${impl}(-)"
+				)
+				break
+			fi
+		done
+	done
+
+	local out=${matches[@]}
+	echo ${out// /,}
+}
+
+# @FUNCTION: python_gen_useflags
+# @USAGE: pattern [...]
+# @DESCRIPTION:
+# Output a list of USE flags for Python implementations which
+# are both in PYTHON_COMPAT and match any of the patterns passed
+# as parameters to the function.
+#
+# Example:
+# @CODE
+# PYTHON_COMPAT=( python{2_7,3_2} )
+# REQUIRED_USE="doc? ( || ( $(python_gen_useflags python2*) ) )"
+# @CODE
+#
+# It will cause the variable to look like:
+# @CODE
+# REQUIRED_USE="doc? ( || ( python_targets_python2_7 ) )"
+# @CODE
+python_gen_useflags() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local impl pattern
+	local matches=()
+
+	for impl in "${PYTHON_COMPAT[@]}"; do
+		for pattern; do
+			if [[ ${impl} == ${pattern} ]]; then
+				matches+=( "python_targets_${impl}" )
+				break
+			fi
+		done
+	done
+
+	echo ${matches[@]}
+}
+
 # @ECLASS-VARIABLE: BUILD_DIR
 # @DESCRIPTION:
 # The current build directory. In global scope, it is supposed to
-- 
1.8.0.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-12-19 21:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-19 21:00 [gentoo-python] [PATCH 1/2] Introduce python_gen_usedep & python_gen_useflags for special deps Michał Górny
2012-12-19 21:00 ` [gentoo-python] [PATCH 2/2] Use python_gen_*() functions to make the deps simpler Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox